添加第三方类库造成的linker command failed with exit code 1 (use -v to see invocation)的错误调试

简介:

        linker command failed with exit code 1 (use -v to see invocation)这个错误貌似遇见并不止一次,当我想用某个第三方类库的时候(如SBJson),我直接把类库文件copy到工程目录里面,然后一编译就出现这样错误(并不是一定会出这样错误),开始以为是网上下载的类库本身问题,所以重新找类库或者其他方式将它添加进去,只要不出错就行,也一直没有深入了解根本问题,今天在给工程添加一个FMDB(SQLIte第三方类库)文件编译时又出现这种错误,一开始以为工程问题,但是新建工程后还是出现这个问题,经过网上查找,得到了解决办法;


Undefined symbols for architecture i386:   "_OBJC_CLASS_$_FMDatabase", referenced from:       objc-class-ref in ViewController.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) 




在网上得到解决办法是:

在工作左边导航栏Target-->Build Phases-->compile Sources中,第三库库的所有.m文件都添加到里面,然后编译通过了;




添加.m文件



根据对比可以看见 in FMDBTest,FMDBTest的Target里添加进去了了一些.m文件



对于以上错误,根据网友解答我的理解是

我们在使用这些第三方类库文件时直接将其拖拽到工程之中,编译的的时候Xcode也没有自动引用,所以造成这样错误,这就需要我们手动添加。假如我们在工程中新建某个文件就不会出现这样问题;


参考  http://blog.hsin.tw/2012/ios-dev-undefined-symbols-for-architecture-i386/



     本文转自新风作浪 51CTO博客,原文链接:http://blog.51cto.com/duxinfeng/1208700,如需转载请自行联系原作者






相关文章
|
C语言
根本解决C程序 ignoring return value of ‘***’
去源码找到出问题的地方,处理一下返回值
188 0
|
4月前
|
机器学习/深度学习 Java Android开发
记录一个Flutter运行的异常FAILURE: Build failed with an exception. What went wrong: A problem occurred config
记录一个Flutter运行的异常FAILURE: Build failed with an exception. What went wrong: A problem occurred config
50 0
|
9月前
|
Java Maven Android开发
成功解决FATAL ERROR in native method: JDWP on getting class status, jvmtiError=JVMTI_ERROR_WRONG_PHASE
成功解决FATAL ERROR in native method: JDWP on getting class status, jvmtiError=JVMTI_ERROR_WRONG_PHASE
|
4月前
|
NoSQL C语言
vscode出现 ERROR: Unable to start debugging. Unexpected GDB output from command “-exec-run“.
vscode出现 ERROR: Unable to start debugging. Unexpected GDB output from command “-exec-run“.
421 0
|
7月前
|
Java
【Java异常】ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2 JDWP exit erro
【Java异常】ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2 JDWP exit erro
90 0
遇到错误怎么办:ndk-build.cmd‘‘ finished with non-zero exit value 2
遇到错误怎么办:ndk-build.cmd‘‘ finished with non-zero exit value 2
343 0
configure: line syntax error near unexpected token `win32-dll'
configure: line syntax error near unexpected token `win32-dll'
270 0
|
Perl
ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1
ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1
578 0
|
iOS开发
iOS linker command failed with exit code 1 (use -v to see invocation)解决方法
iOS linker command failed with exit code 1 (use -v to see invocation)解决方法
1715 0
|
Ubuntu Shell
脚本执行常见错误:build.sh: caller: not found
从Ubuntu 6.10开始,默认使用dash(theDebian Almquist Shell)而不是bash(the GNUBourne-Again Shell)但Login Shell还是bash. 原因是dash更快、更高效,而且它符合POSIX规范。Ubuntu在启动的时候会运行很多shell脚本,使用dash可以加快启动速度。
163 0