2013-01-03 76 views
3

我有一個大型現有的Xcode項目,現在我想添加犰狳庫到它。鏈接犰狳與Xcode

http://arma.sourceforge.net/

我已經下載了它(與MacPorts的),並得到了它使用cmake(就像C++端APP)工作。我沒有將Cmake用於我的大型項目(iPad應用程序),因此我試圖鏈接庫。我查看了與cmake一起工作的xcode-project文件,並將其添加到我的項目中。

補充: 頭搜索路徑中:/ opt /本地/包括 庫搜索路徑中:/ opt/local/lib目錄 其他連接標誌:-larmadillo

我還添加了libarmadillo.3.4.0.dylib到「鏈接庫與二進制文件」

ld: warning: ld: warning: ignoring file /opt/local/lib/libarmadillo.3.4.0.dylib, file was built for unsupported file format (0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0) which is not the architecture being linked (armv7s): /opt/local/lib/libarmadillo.3.4.0.dylibld: warning: ignoring file /opt/local/lib/libarmadillo.dylib, file was built for unsupported file format (0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0) which is not the architecture being linked (armv7s): /opt/local/lib/libarmadillo.dylib 
    ignoring file /opt/local/lib/libz.dylib, file was built for unsupported file format (0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0) which is not the architecture being linked (armv7s): /opt/local/lib/libz.dylib 

    Undefined symbols for architecture armv7s: 
     "_deflateInit_", referenced from: 
    _compress_data in libTestFlight.a(tf_compression.o) 
     "_deflateEnd", referenced from: 
    _compress_data in libTestFlight.a(tf_compression.o) 
     "_deflate", referenced from: 
    _compress_data in libTestFlight.a(tf_compression.o) 
    ld: symbol(s) not found for architecture armv7s 
    clang: error: linker command failed with exit code 1 (use -v to see invocation) 

任何想法我可以解決這個問題?

+0

Daniel,ge stackarnrätt – TompaLompa

+0

我試圖安裝犰狳,並添加了標題和庫搜索路徑,以及'其他鏈接器標誌'。我不知道如何將libarmadillo.3.4.0.dylib添加到「鏈接庫與二進制文件」,雖然。誰能幫忙? – tiswas

回答

13

嘗試添加libz.lib到您的構建目標:

添加libz進行到您的鏈接二進制與圖書館建設

階段
  1. 選擇在Project Navigator
  2. 選擇項目您想要啓用SDK的目標爲
  3. 選擇Build Phases選項卡
  4. 打開鏈接二進制與圖書館相
  5. 點擊+添加新的庫
  6. 查找libz.dylib列表,並將其添加
  7. 重複步驟2 - 6直到您要使用的SDK的所有目標已經libz.dylib

來源:https://testflightapp.com/sdk/doc/1.1/

+0

謝謝。像魅力一樣工作 – TompaLompa

2

我最近有一個類似的問題 - 鏈接犰狳和Xcode。

我會告訴你我是如何修復它的。 兩個步驟是必要的:

1)Xcode的需要「看到」文件libarmadillo.dylib(礦,位於/usr/lib/) - 這是不一樣的,直接使用libarmadillo.3.81.1.dylib

爲了做到這一點,創建一個鏈接到xcode庫(我的,位於/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/)的文件。

總結: $ sudo ln -s /usr/lib/libarmadillo.dylib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/libarmadillo.dylib

2)現在我需要「告訴」 Xcode中包括編譯命令這個庫。

對於:

  1. 打開項目(請確保你做到這一點創建上述鏈接後)
  2. 轉到TARGETS(我只有一個所以...)
  3. 點擊Build Phases選項卡上
  4. 找到「鏈接二進制與圖書館」,並點擊+在新打開的窗口型armadillo(添加項目)
  5. 和現在你應該看到的lib在你面前拉動libarmadillo.dylib,只需添加它!

P.S.在使用犰狳的頭文件中,我使用完整路徑(在我的例子中爲#include "/usr/include/armadillo")包括它

就是這樣, 我希望我可以幫你。