使用gcc链接Apple框架 [英] Linking against Apple frameworks with gcc

查看:198
本文介绍了使用gcc链接Apple框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

解决方案

下面是一个例子: / p>


gcc -framework CoreServices -o test test.c


从苹果gcc的手册页(i686-apple-darwin10-gcc-4.2.1):

除了下面列出的选项外,Apple的GCC也接受并且
几乎传递了链接器ld和
库工具libtool定义的所有选项。通用选项包括-framework,-dynamic,
-bundle,-flat_namespace等等。有关更多详细信息,请参阅ld和libtool man
页面。

从ld的手册页:

  -framework name [,suffix] 
该选项告诉链接器搜索`name.frame-
work / name'框架搜索路径。如果指定了可选的后缀
,则框架首先搜索名称为
的后缀,然后不带(例如,如果不存在,首先查找'name.frame-
work / name_suffix'尝试`name.frame-
work / name')。


I've created some wrapper functions that encapsulate working with CoreAudio, and the goal is to create a C library that I can use with some command line C++ tools. So far things are working well. I took a sample project, modified it, and it builds and runs in XCode. I'd like to skip XCode altogether and build the library with gcc and a Makefile.

How can I link against an Apple Framework? Are Frameworks just shared libraries that I could include in the -l and -L options on gcc?

解决方案

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

这篇关于使用gcc链接Apple框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆