iOS条件链接静态库 [英] iOS conditional link static library

查看:121
本文介绍了iOS条件链接静态库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个为armv7和i386编译的胖静态库.在我的iPhone/iPad项目中,一切正常,但是我只能将应用程序安装在armv7设备上,因此iPhone 3gs及更高版本...

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

有一种方法可以在armv6上运行我的项目,因此我可以将其安装在ipod touch和旧的iPhone版本上(如果我禁用了armv7库,也可以使用).

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

我尝试:

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

命令/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++失败,退出代码为1

Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ failed with exit code 1

因此,有一种方法可以在各种设备上运行我的应用程序,但在为armv7进行编译时链接特定的库?

So there is a way to run my app on all kind of device but link a specific library when compiling for armv7???

感谢帮助!

推荐答案

您需要弱链接该库.打开构建设置并找到其他链接器标志".您需要添加两个条目,第一个是"-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.

这篇关于iOS条件链接静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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