使用 gcc 链接 Apple 框架

发布于 2024-08-11 16:22:42 字数 209 浏览 4 评论 0原文

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

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ι不睡觉的鱼゛ 2024-08-18 16:22:42

这是一个例子:

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

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').
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文