这种问题,通常出现在添加第三方库文件或者多人开发时。

这种问题一般是找不到文件而导致的链接错误。 我们可以从如下几个方面着手排查。

1.以如下错误为例,如果是多人开发,你同步完成后发现出现如下的错误。

  1. Undefined symbols for architecture armv7:
  2. "_OBJC_CLASS_$_MyPageLogViewController", referenced from:
  3. objc-class-ref in BaiduMobStatAppDelegate.o
  4. ld: symbol(s) not found for architecture armv7
  5. 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文件)

  1. Undefined symbols for architecture armv7:
  2. "_OBJC_CLASS_$_BaiduMobStat", referenced from:
  3. objc-class-ref in BaiduMobStatAppDelegate.o
  4. objc-class-ref in MyPageLogViewController.o
  5. (maybe you meant: _OBJC_CLASS_$_BaiduMobStatAppDelegate)
  6. ld: symbol(s) not found for architecture armv7
  7. 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了哪些第三方库,把这些库挨个注释排除,找到出错的那个库,然后按照官方提供的步骤重新添加一遍。

 说法二:

linker command failed with exit code 1 (use -v to see invocation)的错误调试
情况1、

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

[cpp] view plaincopy

  1. Undefined symbols for architecture i386:
  2. "_OBJC_CLASS_$_FMDatabase", referenced from:
  3. objc-class-ref in ViewController.o
  4. ld: symbol(s) not found for architecture i386
  5. 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/

情况2、

linker command failed with exit code 1 (use -v to see invocation)

出现这种情况很可能是,项目中引入了多个相同的文件。删除一个就ok!
情况3、

xcoder的一个编译错误:

linker command failed with exit code 1 (use -v to see invocation)

说明有无法准确找到的函数,函数有重复现象。

造成这个错误的原因是我直接在 .h头文件中实现了几个函数,然后这个头文件又被别的.c文件所引用,有实现的。

所以解决办法是把实现的几个函数单出一个.c文件里去。这样就ok了。

情况4、

把 Valid Architectures  的值改为 armv7

过程:

PROJECT --> Build Settings --> Architectures --> Valid Architectures  他的值本来是 armv7 armv7s  (ios6.0下)  把armv7s 去掉即可

同样的操作

TARGETS -->  Build Settings --> Architectures --> Valid Architectures  做同样的修改

情况5、 很奇葩的情况啊,就是引用第三方的静态库.a 出现了问题. 在模拟器和真机引入的静态库是分开的!!!当然如果你的静态库做成了统一的,那就不会出现情况5.

 

linker command failed with exit code 1的更多相关文章

  1. Xcode出现( linker command failed with exit code 1)错误总结

    这种问题,通常出现在添加第三方库文件或者多人开发时. 这种问题一般是找不到文件而导致的链接错误. 我们可以从如下几个方面着手排查. 先可以再试试一下几个方法:  1,看看是不是有新添加的文件跟之前文件 ...

  2. 出现( linker command failed with exit code 1)错误总结 (转)

    这种问题,通常出现在添加第三方库文件或者多人开发时. 这种问题一般是找不到文件而导致的链接错误. 我们可以从如下几个方面着手排查. 1.以如下错误为例,如果是多人开发,你同步完成后发现出现如下的错误. ...

  3. symbol(s) not found for architecture x86_64 之 linker command failed with exit code 1 (use -v to see invocation)解决方案排查

    这样的错误 ,我的解决方案是, 第一种:   查看他说在 ****.o 中,你要查看这样的关键点,然后去查看,你 项目中有没有引进这样的文件,在项目中查找,看项目中有没有,如果没有那就是没添加进来,你 ...

  4. linker command failed with exit code 1 (use -v to see invocation)

    背景:用U盘从另一台电脑考过来后,出现错误 linker command failed with exit code 1 (use -v to see invocation) 出现这种情况很可能是,项 ...

  5. 出现( linker command failed with exit code 1)错误总结

    这种问题,通常出现在添加第三方库文件或者多人开发时. 这种问题一般是找不到文件而导致的链接错误. 我们可以从如下几个方面着手排查. 1.以如下错误为例,如果是多人开发,你同步完成后发现出现如下的错误. ...

  6. linker command failed with exit code 1 (use -v to see invocation)解决办法

    [cpp] view plaincopy Undefined symbols for architecture i386:     "_OBJC_CLASS_$_FMDatabase&quo ...

  7. Undefined symbols for architecture x86_64: ( linker command failed with exit code 1)

    当出现  linker command failed with exit code 1 (use -v to see invocation) 的错误总结,具体内容如下: Undefined symbo ...

  8. error: linker command failed with exit code 1 解决方法之一

    出现这种错误的原因可能很多,以下是我遇到的一种情况: 向项目中添加了新文件,没有加入compile source 编译报错: ld: symbol(s) not found for architect ...

  9. clang: error: linker command failed with exit code 1 (use -v to see invocation)

    报错提示: ... ld: 6 duplicate symbols for architecture x86_64 clang: error: linker command failed with e ...

  10. IOS Bugs5 linker command failed with exit code 1 (use -v to see invocation)

    Ld /Users/Rubert/Library/Developer/Xcode/DerivedData/OC_Language-emftyzftyvhdpuaxipddjmpnpvox/Build/ ...

随机推荐

  1. UVa12063 Zeros and Ones

    神坑 1竟然还要取模 在后面填数多好的 #include<cstdio> #include<cstring> #include<cstdlib> #include& ...

  2. android布局之线性布局

    LinearLayout 线性布局有两种,分别是水平线性布局和垂直线性布局,LinearLayout属性中android:orientation为设置线性布局当其="vertical&quo ...

  3. 使用r.js进行前端repuirejs的合并压缩

    安装 requirejs npm install -g requirejs 安装好后: 找到刚刚requirejs的安装目录,在该目录下找到r.js,并拷贝待压缩合并项目的根目录下 在项目根目录下创建 ...

  4. android 37 线程通信Looper

    安卓程序的主线程也叫UI线程. 工作线程和主线程的差别:安卓主线程已经调用了Looper.prepare()方法了,已经有一个MessageQueue对象了,所以才可以在工作线程用Handler发消息 ...

  5. Bash函数使用

    #!/bin/bash function Fun_Name() { #function here echo "this is a function" } Fun_Name

  6. codevs 2149 矩形周长(暴力扫描线)

    /* 暴力应该很好理解 不多说了 至于线段树维护的嘛 还没看懂 哪天突然想明白了在写吧 */ #include<iostream> #include<cstdio> #incl ...

  7. 知识点摸清 - - position属性值之relative与absolute

    两者共同特点是: 改变文档流 激活元素left.top.right.bottom.z-index属性 让元素”浮起来“,z-index>0 不同的是: 1.position:relative 会 ...

  8. Datatables+Bootstrap

    http://sandbox.runjs.cn/show/thwac3ec 运行效果 <!DOCTYPE html> <html lang="en"> &l ...

  9. angular调用WCF服务,读取文件夹下图片显示列表,下载另存为图片

    读取文件夹下的文件 public string ReadImagesPaths() { string result = string.Empty; try { string path = System ...

  10. OC - 25.CAKeyframeAnimation

    概述 简介 CAKeyframeAnimation又称关键帧动画 CAKeyframeAnimation是抽象类CAPropertyAnimation的子类,可以直接使用 通过values与path两 ...