For the past week, I have been trying to run some simple OpenCV programs using the terminal. I have tried many tutorials and recommendations from various forums with little success. The problem arises when trying to link the OpenCV header files to my OpenCV main program. For a simple c++ program I would simply execute g++ main.cpp header.hpp
to generate the program executeable. How do I go about linking the necessary OpenCV header files such as <opencv2/highgui/highgui.hpp>
& <opencv2/core/core.hpp>
?
For example, when attempted to execute the sample program from http://docs.opencv.org/2.4/doc/tutorials/introduction/display_image/display_image.html the following occurs:
Desktop Robert$ g++ loadIMG.cpp Undefined symbols for architecture x86_64: "cv::namedWindow(cv::String const&, int)", referenced from: _main in loadIMG-54c517.o "cv::Mat::deallocate()", referenced from: cv::Mat::release() in loadIMG-54c517.o "cv::Mat::copySize(cv::Mat const&)", referenced from: cv::Mat::operator=(cv::Mat const&) in loadIMG-54c517.o "cv::String::deallocate()", referenced from: cv::String::~String() in loadIMG-54c517.o "cv::String::allocate(unsigned long)", referenced from: cv::String::String(char const*) in loadIMG-54c517.o "cv::imread(cv::String const&, int)", referenced from: _main in loadIMG-54c517.o "cv::imshow(cv::String const&, cv::_InputArray const&)", referenced from: _main in loadIMG-54c517.o "cv::waitKey(int)", referenced from: _main in loadIMG-54c517.o "cv::fastFree(void*)", referenced from: cv::Mat::~Mat() in loadIMG-54c517.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Please note: OpenCV has already been built using the following tutorial: http://blogs.wcode.org/2014/10/howto-install-build-and-use-opencv-macosx-10-10/
Any help or direction would be appreciated. Thank you.
See Question&Answers more detail:os