3

我有一个现有的大型 Xcode 项目,现在我想将犰狳库添加到它。

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 添加到您的构建目标:

使用库构建阶段将 libz 添加到您的链接二进制文件中

  1. 在项目导航器中选择您的项目
  2. 选择要为其启用 SDK 的目标
  3. 选择构建阶段选项卡
  4. 使用库阶段打开链接二进制文件
  5. 单击 + 添加新库
  6. 在列表中找到 libz.dylib 并添加
  7. 重复步骤 2 - 6,直到您要使用 SDK 的所有目标都具有 libz.dylib

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

于 2013-01-10T14:49:13.630 回答
3

我最近遇到了一个类似的问题——用 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. 找到'Link Binary With Libraries'并点击+(添加项目)
  5. 在新打开的窗口类型上armadillo,现在你应该看到libarmadillo.dylib你面前的图书馆,只需添加它!

PS 在使用犰狳的头文件中,我使用完整路径包含它(在我的情况下,#include "/usr/include/armadillo"

就是这样,我希望我能帮助你。

于 2013-06-12T01:25:38.540 回答