3

既存の大規模な Xcode プロジェクトがあり、armadillo ライブラリをそれに追加したいと考えています。

http://arma.sourceforge.net/

私はそれを(macportsで)ダウンロードし、Cmakeを使って(ちょうどC++ターミナルアプリとして)動作させました。大規模なプロジェクト (iPad アプリ) に Cmake を使用していないため、ライブラリをリンクしようとしました。cmake で作業している xcode-project ファイルを調べて、同じものをプロジェクトに追加しました。

追加: ヘッダー検索パス: /opt/local/include ライブラリ検索パス: /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)

これを解決する方法はありますか?

4

2 に答える 2

13

libz.lib をビルド ターゲットに追加してみてください。

Libraries Build フェーズでリンク バイナリに libz を追加します。

  1. Project Navigator でプロジェクトを選択します。
  2. SDK を有効にするターゲットを選択します
  3. [ビルド フェーズ] タブを選択します。
  4. リンク バイナリとライブラリ フェーズを開く
  5. + をクリックして新しいライブラリを追加します
  6. リストでlibz.dylibを見つけて追加します
  7. SDK を使用するすべてのターゲットに libz.dylib が含まれるまで、手順 2 ~ 6 を繰り返します。

ソース: https://testflightapp.com/sdk/doc/1.1/

于 2013-01-10T14:49:13.630 に答える
3

私は最近、同様の問題を抱えていました - Armadillo と Xcode をリンクしています。

どのように修正したかをお伝えします。次の 2 つの手順が必要でした。

libarmadillo.dylib1)xcodeはファイル(私のもの、にある)を「見る」必要があります-直接/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(私は1つしか持っていないので...)
  3. Build Phasesタブをクリック
  4. 「Link Binary With Libraries」を見つけて、+(アイテムの追加)をクリックします
  5. 新しく開いたウィンドウ タイプarmadilloで、ライブラリが目の前に表示されているはずです。ライブラリlibarmadillo.dylibを追加するだけです。

PS アルマジロを使用したヘッダーファイル内に、フルパスを使用してインクルードしました(私の場合、#include "/usr/include/armadillo"

そうですか、お役に立てれば幸いです。

于 2013-06-12T01:25:38.540 に答える