iPhone上链接器标志force_load的xcode project- / target-settings-syntax [英] xcode project-/target-settings-syntax for linker flag force_load on iPhone

查看:295
本文介绍了iPhone上链接器标志force_load的xcode project- / target-settings-syntax的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了双重绑定,一方面是我的iPhone应用程序使用的第三方静态库之一,必须在应用程序项目或目标设置中设置链接器标志-all_load,否则app在运行时崩溃,没有找到一些符号,从lib内部调用,另一方面另一方面为另一个第三方静态lib -all_load不能在应用程序级别设置,或者由于重复符号,应用程序将无法构建 - 链接器错误。
为了解决这个问题,我现在想要使用load_all的load_all,因为它的文档与all_load相同,但仅适用于传递的路径或lib文件,而不是所有的库。
force_load的问题是,我没有线索,如何通过xcode project-或target-settings传递路径或文件作为参数。我想到的所有语法可能性都会导致xcode认为它的另一个链接器标志而不是前一个的参数,或者链接器抛出与语法相关的错误,或者与未设置相比,标志根本不执行任何操作。
我还在文本编辑器中打开了.pbxproj文件,手动将其编辑为正确的命令行语法,但是当使用xcode重新加载项目时,它会自动更改语法,将参数解释为force_load作为单独的国旗。

I am confronted with the double bind, that on the one hand for one of the 3rd party static libraries, my iPhone application uses, the linker flag -all_load has to be set in the application project- or target settings, otherwise the app crashes at runtime not finding some symbols, called internally from the lib, on the other hand for another 3rd party static lib -all_load must not be set on application level, or the app won't build thanks to a "duplicate symbols"-linker error. To solve this issue I now want to use force_load instant of load_all, as it due to documentation it does the same like all_load, but only for the passed path or lib-file, instead of all libs. The problem with force_load is, I do not have a clue, how to pass a path or file as parameter with it, when passing it via xcode project- or target-settings. All syntax-possibilities coming to my mind either lead into xcode thinking its another linker flag instead of a parameter to the previous one, or the linker is throwing syntax related errors or the flag simply does nothing at all in comparison to not being set. I also opened the .pbxproj-file in a text-editor to edit it to the correct command line syntax manually, but when reloading the project with xcode, it auto changes the syntax into interpreting the parameter to force_load as a separate flag.

有人对这个问题有所了解吗?

Anyone having an idea on this issue?

Thx,
Kaiserludi。

Thx, Kaiserludi.

推荐答案

我刚试过这个。我已经编译了一个静态armv6,armv7和i386胖二进制PCRE,用于我的iPhone项目。我的项目通常只是将我的库添加到项目中并且链接正常。所以我取消选中libpcre.a的目标成员资格框并重建。正如所料,我为pcre符号得到了一堆丢失的符号链接器错误。然后我打开了目标设置窗口并编辑了Other Linker Flags部分。我添加了:

I just tried this. I've compiled a static armv6, armv7, and i386 fat binary of PCRE for use in my iPhone project. My project normally just has my library added to the project and that links fine. So I unchecked the target membership box for libpcre.a and rebuilt. As expected, I get a bunch of missing symbol linker errors for the pcre symbols. Then I opened the target settings window and edited the "Other Linker Flags" section. I added:

-force_load lib/pcre/libpcre.a

lib 目录与我的project.xcodeproj文件位于同一目录中。

The lib directory is in the same directory as my project.xcodeproj file.

链接正常,所以我知道force_load命令有效(我可以看到它在xcode构建文件时添加到构建标志中)。

It linked fine so I know the force_load command worked (and I can see it added to the build flags when xcode builds the file).

希望有所帮助。

更新:

我还尝试将系统库添加到其他链接器标志 像这样的行:

I also tried adding a system library to the "Other Linker Flags" line like so:

-force_load src/pcre/libpcre.a -force_load ${SDKROOT}/usr/lib/libz.dylib

这也有效。

这篇关于iPhone上链接器标志force_load的xcode project- / target-settings-syntax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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