• “linker command failed with exit code 1”文件路径发生改变使编译出错时


    出现( linker command failed with exit code 1)错误

     

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

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

    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  添加静态库的相应路径。如下图

  • 相关阅读:
    How to function call using 'this' inside forEach loop
    jquery.validate.unobtrusive not working with dynamic injected elements
    Difference between jQuery.extend and jQuery.fn.extend?
    Methods, Computed, and Watchers in Vue.js
    Caution using watchers for objects in Vue
    How to Watch Deep Data Structures in Vue (Arrays and Objects)
    Page: DOMContentLoaded, load, beforeunload, unload
    linux bridge
    linux bridge
    EVE-NG网卡桥接
  • 原文地址:https://www.cnblogs.com/qq449832375/p/4671796.html
Copyright © 2020-2023  润新知