2009-11-22 50 views
20

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

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

回答

24

下面是一个例子:

gcc -framework CoreServices -o test test.c

从苹果的GCC(i686的 - 苹果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'). 
+0

因此,在Mac OS上使用'-framework'链接和使用'-l'链接的区别是搜索路径的权利? – user10607