_cvLoadImage未定义符号链接问题

时间:2014-12-18 17:21:56

标签: c++ macos opencv deep-learning linker-flags

我正在我的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

1 个答案:

答案 0 :(得分:3)

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

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