iOS条件链接静态库
我有一个为armv7和i386编译的胖静态库。在我的 iPhone/iPad 项目中,一切正常,但我只能在 armv7 设备上安装我的应用程序,因此 iPhone 3gs 及更高版本...
有一种方法可以在 armv6 上运行我的项目,这样我可以将其安装在 iPod touch 和旧设备上iPhone版本(如果我禁用armv7库也是如此)。
我尝试这样做:
#ifdef _ARM_ARCH_7
... //include and use of armv7 library
#else
... //not include armv7 library
#endif
但是当我编译我的项目时,我出现链接错误...
命令 /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ 失败,退出代码 1
所以有一种方法可以在所有设备上运行我的应用程序一种设备,但在编译armv7时链接特定的库???
感谢您的帮助!
I have a fat static library compiled for armv7 and i386. In my iPhone/iPad project everything works fine, but i can only install my application on armv7 device so iPhone 3gs and up...
There is a way to run my project on armv6 so i can install it on an ipod touch and an old iphone version (also if i disable the use of armv7 library).
I try this:
#ifdef _ARM_ARCH_7
... //include and use of armv7 library
#else
... //not include armv7 library
#endif
but when i compile my project i have link error...
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ failed with exit code 1
So there is a way to run my app on all kind of device but link a specific library when compiling for armv7???
Thanks for help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要对该库进行弱链接。打开构建设置并找到其他链接器标志。您需要添加两个条目,第一个是“-weak_library”,第二个是库文件的路径(您可能需要搜索传递给链接器的内容以找到它是什么)。
它们需要按该顺序排列,因为此列表将按照它们呈现的顺序转换为链接器的参数。
You need to weak-link that library. Open up build settings and find Other Linker Flags. You need to add two entries, the first is "-weak_library", the second is the path of the library file (you may need to hunt through what's being passed to the linker to find what this is).
They need to be in that order as this list is turned into parameters to the linker in the order they're presented.