出现( linker command failed with exit code 1)错误总结
2023-09-27 14:26:54 时间
这种问题,通常出现在添加第三方库文件或者多人开发时。
这种问题一般是找不到文件而导致的链接错误。 我们可以从如下几个方面着手排查。
1.以如下错误为例,如果是多人开发,你同步完成后发现出现如下的错误。
- Undefined symbols for architecture armv7:
- "_OBJC_CLASS_$_MyPageLogViewController", referenced from:
- objc-class-ref in BaiduMobStatAppDelegate.o
- ld: symbol(s) not found for architecture armv7
- clang: error: linker command failed with exit code 1 (use -v to see invocation)
错误中出现了“MyPageLogViewController”这个类,你可以找到这个类的.m文件, 查看他的Target Membeship, 如下图
如果没有勾选上,点击勾选。然后编译查看。
2. 如果是新添加的第三方库,且不是静态库
先重复第一步过程,然后找到 Build settings->Linking->Other Linker Flags
将此属性修改成-all_load 或者 -ObjC ,这个视情况而定。总之可以多试几次。
3.如果添加的是第三方静态库(.a文件)
- Undefined symbols for architecture armv7:
- "_OBJC_CLASS_$_BaiduMobStat", referenced from:
- objc-class-ref in BaiduMobStatAppDelegate.o
- objc-class-ref in MyPageLogViewController.o
- (maybe you meant: _OBJC_CLASS_$_BaiduMobStatAppDelegate)
- ld: symbol(s) not found for architecture armv7
- clang: error: linker command failed with exit code 1 (use -v to see invocation)
在用到这个库的所有文件中都出现了错误, 如上 BaiduMobStatAppDelegate 类和 MyPageLogViewController类
这种情况就可能是这个静态库路径混乱导致的链接错误
解决方法:Build settings->Search Path->Library Search Paths 添加静态库的相应路径。如下图
如果上面的所有方法都不管用。你可以再试试一下几个方法:
1,看看是不是有新添加的文件跟之前文件同名
2,错误信息中出现了某个类的名字,去原文件中看看#import了哪些第三方库,把这些库挨个注释排除,找到出错的那个库,然后按照官方提供的步骤重新添加一遍。
相关文章
- Incorrect string value: '...' for column 'course' at row 1MySQL插入中文错误:
- springboot出错误Validation failed for object='employee'. Error count: 1
- keytool 错误 java.io.IOException: incorrect AVA format
- 关于iOS 报Command failed with exit 128: git错误额解决方案
- Spring如何加载XSD文件(org.xml.sax.SAXParseException: Failed to read schema document错误的解决方法)
- 解决错误: Failed to load class "org.slf4j.impl.StaticLoggerBinder"
- phpmailer发送邮件出现错误:stream_socket_enable_crypto(): SSL operation failed with code 1.
- npm使用过程中的一些错误解决办法及npm常用命令
- 解决错误: Failed to load class "org.slf4j.impl.StaticLoggerBinder"
- iOS 使用AFNetworking遇到错误 Request failed: unacceptable content-type: text/html
- PHP error_reporting() 函数设置应该报告何种 PHP 错误
- Windows10 安装或卸载软件时提示“ the error code is 2503/2502”错误
- Centos7使用yum命令报错:“Could not resolve host: mirrors.aliyun.com; 未知的错误“
- Software caused connection abort: recv failed 错误介绍
- Android Studio 4.1 不报错 代码不提示 运行时错误看不到
- FreeBSD 的root 用户修改 shell 后发生错误无法登入的问题解决
- 【错误记录】Ubuntu 安装软件报错 ( 下列软件包有未满足的依赖关系:E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。 )
- 【错误记录】Mac 中 IntelliJ IDEA 运行 Python 程序报错 ( End of statement expected )
- Nginx: [emerg] getpwnam(“www”) failed错误
- toad安装错误—Failed to Download products and updates
- android 真机调试出现错误 INSTALL_FAILED_INSUFFICIENT_STORAGE 的解决方法。
- 启动 Eclipse 弹出“Failed to load the JNI shared library jvm.dll”错误
- 【我的Android进阶之旅】Android目录过长造成错误:Failed to crunch file abc_textfield_search_activated_mtrl_alpha.9.png