2

我正在我的 mac osx 上编译 conv-net ( http://conv-net.sourceforge.net/ ) 深度学习库 opencv 和 c++,我似乎无法解决这个错误。这似乎是一个链接问题。所有的 opencv 库都是为 64 位编译的,我尝试在 cmake 中设置 -m64 标志,不,仍然无法正常工作。

我不知道 _cvLoadImage() 链接到哪个库???我正确链接到正确的库,但无法修复这个错误??????

Undefined symbols for architecture x86_64:
  "_cvLoadImage", referenced from:
      _main in testimg.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]: *** [testimg] Error 1
make[1]: *** [CMakeFiles/testimg.dir/all] Error 2

我做了一个链接器的-v输出,它显示了这个......

Linking CXX executable testimg
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o testimg -search_paths_first -headerpad_max_install_names CMakeFiles/testimg.dir/tst/testimg.cpp.o libcvconvnet.a -lopencv_core -lopencv_highgui -lexpat -lopencv_imgproc -lopencv_photo -lopencv_shape -lopencv_features2d -lopencv_ml -lopencv_objdetect -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib/darwin/libclang_rt.osx.a
4

1 回答 1

3

在 opencv 3.1.0 中,我无法在 中找到丢失的符号,/usr/local/lib/libopencv_highgui.dylib而是在/usr/local/lib/libopencv_imgcodecs.dylib.

所以添加-lopencv_imgcodecs到你的编译命令中。

于 2016-03-21T15:43:47.213 回答