使用gcc链接Apple框架

时间:2009-11-22 21:56:08

标签: gcc core-audio macos-carbon

我已经创建了一些封装使用CoreAudio的封装函数,目标是创建一个可以与某些命令行C ++工具一起使用的C库。到目前为止,事情进展顺利。我拿了一个示例项目,对其进行了修改,然后在XCode中构建并运行。我想完全跳过XCode并使用gcc和Makefile构建库。

如何链接Apple Framework?框架是否只是共享库,我可以包含在gcc的-l和-L选项中?

1 个答案:

答案 0 :(得分:25)

以下是一个例子:

  

gcc -framework CoreServices -o test test.c

来自Apple的gcc手册页(i686-apple-darwin10-gcc-4.2.1):

   In addition to the options listed below, Apple's GCC also accepts and
   passes nearly all of the options defined by the linker ld and by the
   library tool libtool.  Common options include -framework, -dynamic,
   -bundle, -flat_namespace, and so forth.  See the ld and libtool man
   pages for further details.

来自ld的手册页:

 -framework name[,suffix]
             This option tells the linker to search for `name.frame-
             work/name' the framework search path.  If the optional suffix
             is specified the framework is first searched for the name
             with the suffix and then without (e.g. look for `name.frame-
             work/name_suffix' first, if not there try `name.frame-
             work/name').