i am compiling conv-net (http://conv-net.sourceforge.net/) deep learning library opencv and c++ on my mac osx and i cant seem to get through this error. This seems to be a linking issue. All the opencv libraries are compiled for 64 bit, i tried setting -m64 flag in cmake, nope still not working.
I dont know which library _cvLoadImage() links into??? i am linking properly to proper libraries but cant fix this one error?????
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
i did a -v output of the linker and it shows this...
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
In opencv 3.1.0 I wasn't able to find the missing symbols in
/usr/local/lib/libopencv_highgui.dylib
but rather in/usr/local/lib/libopencv_imgcodecs.dylib
.So add
-lopencv_imgcodecs
to your compilation command.