XCODE:<iOS>other linker flags

來源:互聯網
上載者:User

標籤:

在工程中匯入XMPP第三庫時,出現link錯誤,錯誤如下:
Undefined symbols for architecture i386:
  "_iconv", referenced from:
      _mem_cd_iconv in libidn.a(striconv.o)
      _str_cd_iconv in libidn.a(striconv.o)
     (maybe you meant: _str_iconv, _str_cd_iconv , _mem_cd_iconv )
  "_iconv_close", referenced from:
      _str_iconv in libidn.a(striconv.o)
  "_iconv_open", referenced from:
      _str_iconv in libidn.a(striconv.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)


起初我以為是路徑問題,庫檔案沒導好。但是反覆檢查發現,不是這樣的。libidn.a這個靜態庫已經在Link Binary With Libraries裡。在網上查了很久的資料,最後在中午的時候想到other linker flags這個參數設定,於是找到發現這個參數設定是-all-load,將它刪除後,再運行無錯誤,問題解決。下午就查了些關於這個參數的一些資料。


 
包含靜態庫時候需要在Target的Other linker flags裡面加上值:-objC,-all_load,-force_load 對於64位機子和iPhone OS應用 解決方案是使用-all_load 或者 -force_load。 -all_load強迫連結器從它能看見的所有文檔中載入所有的對象檔案,甚至那些沒有OC代碼的文檔。 -force_load適用於Xcode3.2+版本,它允許finer得到文檔載入的控制。每一個-force_load操作必須跟著一個文檔路徑,文檔中的每一個對象檔案將會被載入。 -all_load就是會載入靜態庫檔案中的所有成員, -ObjC就是會載入靜態庫檔案中實現一個類或者分類的所有成員, -force_load(包的路徑)就是會載入指定路徑的靜態庫檔案中的所有成員。 舉個例子 當連結一個包含類別的OC靜態庫時候,將會得到一個運行時異常:"selector not recognized"。你需要設定Other Linker Flags的值為-ObjC就OK了

XCODE:<iOS>other linker flags

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.