根据 OSX 版本或处理器版本将通用二进制链接到不同的动态库
这实际上是两个问题合而为一,但我怀疑他们有相似的答案。
我有一个程序依赖于 X11 库,该库在 OS10.4 上具有不同的名称并且位于不同的位置(与 10.5 和 10.6 相比)。
这个程序还依赖于一个不能在 ppc 上运行的库。在编译 ppc 时可以删除这种依赖关系,但我想尽可能使用这个库(因为它提供了几个数量级的加速)。
所以两个问题是:
如何链接到不同操作系统版本中不同位置的动态库?或者换句话说 - 如何使动态链接器从不同操作系统版本上的不同位置加载库?
如何将通用二进制链接的某些部分(英特尔部分)链接到某个库,同时不将 ppc 部分链接到该库?
当然,如果我的问题还有其他解决方案,我也很感兴趣。
This is actually two questions in one, but I suspect they have similar answers.
I have a program which has a dependency on an X11 library which on OS10.4 has a different name and is in a different place (compared to on 10.5 and 10.6).
This same program also has a dependency on a library which does not work on ppc. This dependency can be removed when compiling for ppc, but I would like to use this library when I can (as it gives speedups of several orders of magnitude).
So the two questions are:
How do I link to a dynamic library which in a different place in different OS versions? Or rephrased - how do I make the dynamic linker load a library from a different place on different OS versions?
How do I make some parts (the Intel parts) of a universal binary link to a library while not having the ppc parts link to that library?
Of course, if there are other solutions to my problems, I am also interested.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Apple GCC 手册提到 -Xarch :
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/gcc.1.html
的文档说
因此,您可能想要执行以下操作:
如果您是从 XCode 构建的,则可以在 Target 设置面板中执行此操作。转到“其他链接器标志”,然后单击面板左下角的齿轮按钮并选择“添加构建设置条件”,它将允许您为每个体系结构指定不同的链接器标志。
The Apple GCC manual mentions -Xarch :
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/gcc.1.html
The documentation for that says
So presumably you'd want to do something like:
If you're building from XCode, you can do this in the Target settings panel. Go to "Other Linker Flags", then click the gear button in the lower left corner of the panel and choose "Add Build Setting Condition", and it will let you specify different linker flags per-architecture.