添加第三方类库造成的Undefined symbols for architecture i386:编译错误

来源:互联网 发布:剩女为什么单身知乎 编辑:程序博客网 时间:2024/04/28 18:20
1.原因:
如果是源码编译的话,一般就只某些头文件没有添加到src编译里面。但是对于添加库编译,一般是库的编译路径设置不正确(比如arm的版本、模拟器或者真机的不同版本库引用错误或者重复引用一起编译器不知道如何选择)、或者库没有添加到lib path中。

2.解决:
2.1对于外部库真机和模拟器的库引用重复,可以参考
http://blog.csdn.net/forlong401/article/details/9304883
2.2 如果这些库是系统自带库,那就是在Build Phases的link binary with libraries里面添加即可。


3.参考(虽然很多写的都不太正确,但是可以参考一下):

http://my.csdn.net/kaixinnow2008/code/detail/4209

解决方法:
先点击方案(左边列表,点击方案的图示)
选择target
选择页签Build Phases
Compile Source
如果没展开的话先展开
向下找加号,点击加号,将这个target需要的.m档案的头文件都加入吧
(如果只有一个 就把左右的.h档案都加入)
这样就应该可以了

http://blog.csdn.net/itianyi/article/details/8499504

1,如何解决XCODE中错误: Undefined symbols for architecture i386 error

出现Undefined symbols for architecture i386这种错误一般是你用模拟器作为目标,但编译的时候找不到相关的库文件,需要做的就是把库文件所在的位置添加到library search path中。

其它原因可参考下面网址:http://stackoverflow.com/questions/6984368/undefined-symbols-for-architecture-i386-objc-class-skpsmtpmessage-refere    

还有另外一个:http://stackoverflow.com/questions/6610709/undefined-symbols-for-architecture-i386


2,Undefined symbols for architecture i386: _OBJC_CLASS_$_SKPSMTPMessage", referenced from: error

答案:You can get this type of error if your class' .m file is not listed under the "Compile Sources" step of the "Build Phases" tab of your target. Normally Xcode does this for you, but sometimes it loses the plot and you need to add the .m file manually.

   3,请问为什么在link with lib 种添加  libxml2.dylb  后  引用不了<libxml/tree.h>  老是找不到头文件?

答案:XCODE ,  Project -> Edit Project Settings -> Build Settings

You need to add “/usr/include/libxml2″ to the “Header Search Paths” and you need to add “-lxml2″ to the “Other Linker Flags”.
原创粉丝点击