2009-11-22 45 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