xcode project-/target-settings-syntax for linker flag force_load on iPhone [英] xcode project-/target-settings-syntax for linker flag force_load on iPhone

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

问题描述

我遇到了双重绑定.一方面,对于我的 iPhone 应用程序使用的第 3 方静态库之一,必须在应用程序项目或目标设置中设置链接器标志 -all_load.否则,应用程序在运行时崩溃,找不到从 lib 内部调用的某些符号.另一方面,对于另一个 3rd 方静态库,-all_load 不得在应用程序级别设置,否则由于重复符号"链接器错误,应用程序将无法构建.

I am confronted with the double bind. 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 run-time 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.

为了解决这个问题,我现在想使用 force_load 而不是 load_all,因为它与 all_load 的作用相同,但仅适用于传递的路径或库文件,而不是所有库.

To solve this issue, I now want to use force_load instead 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.

force_load 的问题是,当通过 XCode 项目或目标设置传递路径或文件时,我不知道如何将路径或文件作为参数传递.我尝试的所有语法可能性要么导致 xcode 认为它是另一个链接器标志而不是前一个参数的参数,要么链接器抛出与语法相关的错误,要么该标志根本什么都不做.

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 I tried either lead xcode to thinking it's another linker flag instead of a parameter to the previous one, or the linker throwing syntax related errors, or the flag simply does nothing at all.

我还在文本编辑器中打开了 .pbxproj 文件,以手动将其编辑为正确的命令行语法.但是当使用 XCode 重新加载项目时,它会自动将语法更改为将参数解释为 force_load 作为单独的标志.

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 have an idea on this issue?

推荐答案

我刚试过这个.我已经编译了 PCRE 的静态 armv6、armv7 和 i386 fat 二进制文件,用于我的 iPhone 项目.我的项目通常只是将我的库添加到项目中,并且链接很好.所以我取消选中 libpcre.a 的目标成员资格框并重建.正如预期的那样,我得到了一堆 pcre 符号丢失的符号链接器错误.然后我打开目标设置窗口并编辑其他链接器标志"部分.我补充说:

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

希望对您有所帮助.

更新:

我还尝试将系统库添加到Other Linker Flags"行,如下所示:

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

这也有效.

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

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