【问题标题】:Linking against Apple frameworks with gcc使用 gcc 链接 Apple 框架
【发布时间】:2010-12-19 07:18:06
【问题描述】:

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

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

【问题讨论】:

    标签: gcc core-audio macos-carbon


    【解决方案1】:

    这是一个例子:

    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').
    

    【讨论】:

    • 那么在 Mac OS 上链接 -framework 和链接 -l 的区别是搜索路径对吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-24
    • 1970-01-01
    • 1970-01-01
    • 2011-02-07
    • 2012-08-11
    相关资源
    最近更新 更多