出現( linker command failed with exit code 1)錯誤總結,linkerfailed

來源:互聯網
上載者:User

出現( linker command failed with exit code 1)錯誤總結,linkerfailed

這種問題,通常出現在添加第三方庫檔案或者多人開發時。

這種問題一般是找不到檔案而導致的連結錯誤。 我們可以從如下幾個方面著手排查。

 

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了哪些第三方庫,把這些庫挨個注釋排除,找到出錯的那個庫,然後按照官方提供的步驟重新添加一遍。

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.