代码之家  ›  专栏  ›  技术社区  ›  Dr. Watson

用gcc链接苹果框架

  •  20
  • Dr. Watson  · 技术社区  · 16 年前

    我已经创建了一些封装函数,它封装了CyeOdio的工作,目标是创建一个C库,我可以用一些命令行C++工具使用。到目前为止,一切进展顺利。我取了一个示例项目,对它进行了修改,它在Xcode中构建和运行。我想完全跳过xcode,用gcc和makefile构建库。

    如何链接到苹果框架?框架是否只是共享库,我可以在gcc的-l和-l选项中包含这些库?

    1 回复  |  直到 12 年前
        1
  •  24
  •   Jeremy L    16 年前

    下面是一个例子:

    gcc -framework CoreServices -o test test.c

    从苹果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').
    
    推荐文章