对于Xcode中的C ++项目,无法在64位mac上构建opencv 2.4

时间:2014-01-29 18:21:37

标签: c++ xcode macos opencv

在环顾四周并尝试我在SO上找到的每个选项后,我对如何在我的Mac上加载用于架构x86_64的OpenCV库感到困惑。这里有一些背景信息:

enter image description here

第一个文件夹包含 Android SDK 。第二个是 iPhone框架,它使用 i386 armv7 架构。

现在,我想在 Xcode 中创建一个简单的“Hello World” C ++ 应用程序,该应用程序需要 x86_64 架构的正确库。 / p>

我已经查看了此tutorial以及其他人发布的步骤,如下所示:

  • mkdir build
  • cd build
  • cmake -G“Unix Makefiles”..
  • make -j8
  • sudo make install

对于所有版本(OpenCV-2.4.6.1除外),该过程在“make -j8”处失败。我每次都得到同样的错误:

Linking CXX shared library ../../lib/libopencv_core.dylib

Undefined symbols for architecture x86_64:

  "___sincos_stret", referenced from:

      cv::RotatedRect::points(cv::Point_<float>*) const in matrix.cpp.o

      cv::RotatedRect::boundingRect() const in matrix.cpp.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make[2]: *** [lib/libopencv_core.2.4.3.dylib] Error 1

make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2

make[1]: *** Waiting for unfinished jobs....

[ 28%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfThreading.cpp.o

[ 28%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTileDescriptionAttribute.cpp.o

[ 28%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTiledInputFile.cpp.o

[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTiledMisc.cpp.o

[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTiledOutputFile.cpp.o

[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTiledRgbaFile.cpp.o

[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTileOffsets.cpp.o

[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTimeCode.cpp.o

[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfTimeCodeAttribute.cpp.o

[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfVecAttribute.cpp.o

[ 29%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfVersion.cpp.o

[ 29%] [ 30%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfWav.cpp.o

Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfZipCompressor.cpp.o

Linking CXX static library ../lib/libIlmImf.a

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThread.cpp.o) has no symbols

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThreadMutex.cpp.o) has no symbols

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThreadSemaphore.cpp.o) has no symbols

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThreadSemaphorePosixCompat.cpp.o) has no symbols

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThread.cpp.o) has no symbols

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThreadMutex.cpp.o) has no symbols

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThreadSemaphore.cpp.o) has no symbols

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../lib/libIlmImf.a(IlmThreadSemaphorePosixCompat.cpp.o) has no symbols

[ 30%] Built target IlmImf

make: *** [all] Error 2

pdls-mbp:build pdl$ 

使用OpenCV-2.4.6.1,进程在“sudo make install”时失败,我收到以下错误:

Linking CXX shared library ../../lib/libopencv_core.dylib

Undefined symbols for architecture x86_64:

  "___sincos_stret", referenced from:

      cv::RotatedRect::points(cv::Point_<float>*) const in matrix.cpp.o

      cv::RotatedRect::boundingRect() const in matrix.cpp.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make[2]: *** [lib/libopencv_core.2.4.6.dylib] Error 1

make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2

make: *** [all] Error 2

Lucys-MacBook-Pro:build pdl$ 

当我使用Homebrew安装OpenCV时,opencv安装在use / local / opt / opencv中,我可以看到lib文件夹下的所有dylib文件:

Contents of lib folder

所有这一切都让我感到困惑,因为我觉得我只需要一个.a库文件,不是吗?

我在/usr/local/Cellar/opencv/2.4.6.1/lib中找到了与HomeBrew一起安装的dylib文件,但是当我尝试选择要添加的框架和库时,它们不会显示在列表中。相反,这就是我所看到的:

Choose frameworks and libraries to add:

Aldo,一直关注MacPorts tutorial

1 个答案:

答案 0 :(得分:2)

您是否考虑过使用macports?它有opencv 2.4.8 available

所以在installing macports之后,你所经历的所有废话都被简化为:

$ sudo port selfupdate
$ sudo port install opencv

如果你想要一个或两个变种,例如OpenCL和Python支持,那就是:

$ sudo port install opencv +opencl +python27

以及二进制文件/库/将安装到/opt/local/...中的任何内容。