关于iOS静态库 编译失败总结
2014-04-17 11:01
399 查看
1、"std::ios_base::Init::~Init()", referenced from
出现这样的编译问题,是需要再加进libstdc++.dylib和libstdc++.6.dylib(为6.1使用,xcode5以后默认complier也可以编译通过,本人用xcode5.1上编译,报此类问题,加上这两个类库就解决了)
2、Undefined symbols for architecture i386:
"std::ios_base::Init::Init()", referenced from:
__GLOBAL__I_a in libUPPayPlugin.a(UPPasswordTool.o)
"std::ios_base::Init::~Init()", referenced from:
__GLOBAL__I_a in libUPPayPlugin.a(UPPasswordTool.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(这类问题应该是真机版 和模拟器版的没区分开,导致编译失败)
3、关于链接库,要多了解iOS中的几种指令集:
目前ios的指令集有以下几种:
armv6
iPhone
iPhone2
iPhone3G
第一代和第二代iPod Touch
armv7
iPhone4
iPhone4S
armv7s
iPhone5
iPhone5C
arm64
iPhone5S
机器对指令集的支持是向下兼容的,因此armv7的指令集是可以运行在iphone5S的,只是效率没那么高而已~
Build Active Architecture Only : 只是否只编译当前适用的指令集。
================================================
现在是2014年初,其实4和4S的用户还是蛮多的,而iphone3之类的机器几乎没有了,所以我们的指令集最低必须基于armv7.
因此,Architecture的值选择:armv7 armv7s arm64
PS:选arm64时需要最低支持5.1.1:
1,如果想自己的app在各个机器都能够最高效率的运行,则需要将Build Active Architecture Only改为NO,Valid architectures选择对应的指令集:armv7 armv7s arm64。这个会为各个指令集编译对应的代码,因此最后的 ipa体积基本翻了3倍,Release版本必须NO。
2,如果想让app体积保持最小,则现阶段应该选择Valid architectures为armv7,这样Build Active Architecture Only选YES或NO就无所谓了
了解以上这些就是打包的时候可以注意一下,防止编译时出现architectures烦人的问题。
原文链接:http://blog.csdn.net/run_fly/article/details/21036347
4、编译的时候一定要吧头文件和包正确导入,如何编译失败,首先查看Build setting 下 library search path下的.a文件路径是否正确。
5、模拟器调试时加入 .a 没选arm64的话,测试工程不能选64。architect 要保持一致,一般arm指令集可向下兼容。
下面附带stackoverflow有人分析的几个原因
http://stackoverflow.com/questions/6429494/undefined-symbols-for-architecture-armv7
The common causes for "Undefined symbols for architecture armv7" are:
You import a header and do not link against the correct library. This is common, especially for headers for libraries like QuartzCore since it is not included in projects by default. To resolve:
Add the correct libraries in the
If you want to add a library outside of the default search path you can include the path in the
in the Build Settings and add
You copy files into your project but forgot to check the target to add the files to. To resolve:
Open the
expand
upvote Cortex's answer below as well.
You include a static library that is built for another architecture like i386, the simulator on your host machine. To resolve:
If you have multiple library files from your libraries vendor to include in the project you need to include the one for the simulator (i386) and the one for the device (armv7 for example).
Optionally, you could create a fat static library that
contains both architectures.
出现这样的编译问题,是需要再加进libstdc++.dylib和libstdc++.6.dylib(为6.1使用,xcode5以后默认complier也可以编译通过,本人用xcode5.1上编译,报此类问题,加上这两个类库就解决了)
2、Undefined symbols for architecture i386:
"std::ios_base::Init::Init()", referenced from:
__GLOBAL__I_a in libUPPayPlugin.a(UPPasswordTool.o)
"std::ios_base::Init::~Init()", referenced from:
__GLOBAL__I_a in libUPPayPlugin.a(UPPasswordTool.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(这类问题应该是真机版 和模拟器版的没区分开,导致编译失败)
3、关于链接库,要多了解iOS中的几种指令集:
目前ios的指令集有以下几种:
armv6
iPhone
iPhone2
iPhone3G
第一代和第二代iPod Touch
armv7
iPhone4
iPhone4S
armv7s
iPhone5
iPhone5C
arm64
iPhone5S
机器对指令集的支持是向下兼容的,因此armv7的指令集是可以运行在iphone5S的,只是效率没那么高而已~
Build Active Architecture Only : 只是否只编译当前适用的指令集。
================================================
现在是2014年初,其实4和4S的用户还是蛮多的,而iphone3之类的机器几乎没有了,所以我们的指令集最低必须基于armv7.
因此,Architecture的值选择:armv7 armv7s arm64
PS:选arm64时需要最低支持5.1.1:
1,如果想自己的app在各个机器都能够最高效率的运行,则需要将Build Active Architecture Only改为NO,Valid architectures选择对应的指令集:armv7 armv7s arm64。这个会为各个指令集编译对应的代码,因此最后的 ipa体积基本翻了3倍,Release版本必须NO。
2,如果想让app体积保持最小,则现阶段应该选择Valid architectures为armv7,这样Build Active Architecture Only选YES或NO就无所谓了
了解以上这些就是打包的时候可以注意一下,防止编译时出现architectures烦人的问题。
原文链接:http://blog.csdn.net/run_fly/article/details/21036347
4、编译的时候一定要吧头文件和包正确导入,如何编译失败,首先查看Build setting 下 library search path下的.a文件路径是否正确。
5、模拟器调试时加入 .a 没选arm64的话,测试工程不能选64。architect 要保持一致,一般arm指令集可向下兼容。
下面附带stackoverflow有人分析的几个原因
http://stackoverflow.com/questions/6429494/undefined-symbols-for-architecture-armv7
The common causes for "Undefined symbols for architecture armv7" are:
You import a header and do not link against the correct library. This is common, especially for headers for libraries like QuartzCore since it is not included in projects by default. To resolve:
Add the correct libraries in the
Link Binary With Librariessection of the
Build Phases.
If you want to add a library outside of the default search path you can include the path in the
Library Search Pathsvalue
in the Build Settings and add
-l{library_name_without_lib_and_suffix}(eg. for libz.a use
-lz) to the
Other Linker Flagssection of
Build Settings.
You copy files into your project but forgot to check the target to add the files to. To resolve:
Open the
Build Phasesfor the correct target,
expand
Compile Sourcesand add the missing
.mfiles. If this is your issue please
upvote Cortex's answer below as well.
You include a static library that is built for another architecture like i386, the simulator on your host machine. To resolve:
If you have multiple library files from your libraries vendor to include in the project you need to include the one for the simulator (i386) and the one for the device (armv7 for example).
Optionally, you could create a fat static library that
contains both architectures.
相关文章推荐
- ios 静态库编译总结
- iOS:关于iPhone连接Xcode时,RSA加密失败的一点总结
- iOS: FFmpeg编译和使用问题总结
- 关于iOS基础总结(8)--关于Swift与OC的不同
- iOS开发小记:关于环信Demo3.0的使用总结以及昵称和头像问题的研究与解决
- mac系统编译 ffmpeg ios 静态库
- iOS关于静态库的使用和制作注意和学习
- SCJP中抛出异常和编译失败的总结
- 关于iOS App 国际化和本地化 的一些总结:国际化 vs 本地化(Internationalization vs Localization)
- 关于ios的定位服务总结
- Xcode环境下osip,eXosip, openssl的静态库编译方法(编译出来给IOS使用)
- iOS Xcode编译Undefined symbols for architecture xxx 错误总结
- 关于用上线IOS上线的一些总结与思考
- 【转】编译Lua5.3.0的iOS静态库
- 为iOS 8编译libjpeg-turbo静态库
- iOS 之 PJSIP 笔记(一) 编译多平台支持的静态库
- 关于expat第三方源码生成静态库并被其他程序加载的总结
- 关于QtSerialPort编译在Qt4.8.6+Qt creator+Win7 / XP环境下的总结
- 关于dll加载失败原因总结
- 关于ios颜色渐进的总结