23

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

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

4

1 回答 1

29

Here's an example:

gcc -framework CoreServices -o test test.c

From the man page of Apple's 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.

And from ld's man page:

 -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').
于 2009-11-22T22:30:24.240 回答