linker command failed with exit code 1 (use -v to see invocation)解决办法
2017-08-15 20:03
731 查看
问题如下:
报错信息显示是连接时发生了错误,并且可以看到有编译后产生的目标文件如AACPlayer.o等,也证明编译过程没有出现问题。
网上找了好多文章,大部分说的都是关于第三方库,或者导入文件重复的问题
文章的传送门在这里:文章链接
但是如果你的像我的一样,并没有使用第三方或者其他问题都被排除了 且还是没有解决问题的话,那么请接下去看,这里是我对刚才那篇文章的补充:
检查工程里面是否使用了全局变量,如果这个工程中有同名的全局变量时,也会报以上的错误。如:
在ViewController.m 和AACPlayer.m文件里,都用了一个名为“port”的全局变量
虽然在各自的文件里它们都能被使用,编译器编译时也能够编译,但是一旦到了链接时,就会报以上的错误
原因
这是因为:链接时,整个工程的函数和全局变量是外链接属性,即每个函数和全局变量 将来在整个工程所有的文件都能够被访问,可以粗略地理解为“合为一体”,因此报同名冲突。解决办法:
1. 把没有到的全局变量注释掉。如注释掉AACPlayer.m中的port。build,成功
2. 将明显不会在其他文件中引用的函数或者全局变量 用“static”关键字修饰,使之链接属性改成内链接。
如将AACPlayer.m中的port(或者ViewController.m)前面用“static”修饰,build,成功。
到此结束
相关文章推荐
- clang: error: linker command failed with exit code 1 (use -v to see invocation) 解决办法
- linker command failed with exit code 1 (use -v to see invocation)报错解决办法
- 【linker command failed with exit code 1 (use -v to see invocation)】错误的解决办法
- 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)解决办法
- 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)解决办法
- iOS开发中Xcode编译错误 linker command failed with exit code 1 (use -v to see invocation) 的解决办法
- clang: error: linker command failed with exit code 1 (use -v to see invocation)解决办法
- linker command failed with exit code 1 (use -v to see invocation)解决办法
- [置顶] 简易的解决方式linker command failed with exit code 1 (use -v to see invocation)
- 解决“linker command failed with exit code 1(use -v to see invocation)”的问题
- ios clang: error: linker command failed with exit code 1 (use -v to see invocation)解决方法
- IOS如何解决烦人的“clang: error: linker command failed with exit code 1 (use -v to see invocation)”问题
- 解决 linker command failed with exit code 1 (use -v to see invocation) 方法
- error: linker command failed with exit code 1 (use -v to see invocation)怎么解决
- linker command failed with exit code 1 (use -v to see invocation),经典Xcode编译错误的出现和解决!
- Xcode编译常见错误解决: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)解决方法
- xmpp框架搭建以及linker command failed with exit code 1 (use -v to see invocation)问题的解决