2

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
pbu
  • 2,982
  • 8
  • 44
  • 68
  • `cvLoadImage()` is found in the HighGUI module. Do you know where you installed OpenCV, and if so can you run `nm /usr/local/lib/libopencv_highgui.dylib | grep cvLoadImage` (or similar; change the path appropriately) and tell us if you get something similar to `0000000000016ef0 T _cvLoadImage`? – Iwillnotexist Idonotexist Dec 18 '14 at 17:37
  • @IwillnotexistIdonotexist Add that comment as an answer. – karlphillip Dec 20 '14 at 23:44
  • @karlphillip But it's not an answer... All I was saying is that's in HighGUI and that command only checks whether the symbol is defined in the library! It doesn't fix anything and change anything! – Iwillnotexist Idonotexist Dec 21 '14 at 04:50

1 Answers1

3

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.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
puneetk
  • 123
  • 1
  • 10