Undefined symbols for architecture x86_64 error when linking OpenCV in Xcode -
i have problem linking opencv in xcode. installed opencv using brew:
brew tap homebrew/science sudo brew install opencv
i started new xcode commandline project, added /usr/local/lib
, /usr/local/include
library , header search path. added output of pkg-config --libs opencv
other linker options
.
but when try compile small sample program:
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> int main(int argc, char *argv[]) { cv::mat test; cv::namedwindow( "display window", cv_window_autosize );// create window display. cv::waitkey(0); // wait keystroke in window return 0; }
i following linker error:
undefined symbols architecture x86_64: "cv::namedwindow(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)", referenced from: _main in main.o ld: symbol(s) not found architecture x86_64
but able compile program on command line using
g++ `pkg-config --cflags --libs opencv` prog.cpp
so think problem way xcode set up. not able determine different between way xcode compiles , commandline argument.
does know reason error or has idea try investigate problem?
in xcode create new group inside project, right click it, choose add files project, navigate /usr/local/lib
folder , add following basic libraries:
libopencv_core.dylib, libopencv_ml.dylib, libopencv_video.dylib
in previous versions of opencv library names be:
libcxcore.dylib, libcvaux.dylib, libcv.dylib, libhighgui.dylib, libml.dylib
(the libraries may in path depending on method used install opencv on mac.)
edit:
the above lines should not necessary if including dynamic libraries in linking phase op explains.
select project, go build settings tab, filter c++ standard library, , set parameter libstdc++ (gnu c++ standard library).
Comments
Post a Comment