I already searched for solutions, but cannot find any. This is still new to me, so pardon me if it is trivial. My OS is Ubuntu 16.04 by the way.
I have installed OpenCV 3 binded with Python using pyimagesearch tutorial. One of the most completed install tutorial for OpenCV I have ever encountered. So, after using Python with OpenCV for quite some time, I need to step up my game by using OpenCV with C++. I have copied and pasted the code for loading and displaying image for C++ from this site. Then, I compiled my program with this command:
g++ `pkg-config --cflags --libs opencv` test.cpp -o opencv
At first, I got this error:
/usr/bin/ld: cannot find -lippicv
After found the solution (by removing the -lippicv from opencv.pc), I got this output:
/tmp/ccriaGtQ.o: In function `main':
test.cpp:(.text+0x9d): undefined reference to `cv::imread(cv::String const&, int)'
test.cpp:(.text+0x128): undefined reference to `cv::namedWindow(cv::String const&, int)'
test.cpp:(.text+0x17d): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
test.cpp:(.text+0x1a5): undefined reference to `cv::waitKey(int)'
/tmp/ccriaGtQ.o: In function `cv::String::String(char const*)':
test.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x4d): undefined reference to `cv::String::allocate(unsigned long)'
/tmp/ccriaGtQ.o: In function `cv::String::~String()':
test.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
/tmp/ccriaGtQ.o: In function `cv::Mat::~Mat()':
test.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'
/tmp/ccriaGtQ.o: In function `cv::Mat::operator=(cv::Mat const&)':
test.cpp:(.text._ZN2cv3MataSERKS0_[_ZN2cv3MataSERKS0_]+0x115): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
/tmp/ccriaGtQ.o: In function `cv::Mat::release()':
test.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
This is driving me crazy. I am a still a beginner for this kind of things. So, any help will be very appreciated.
Thanks.
g++ test.cpp -o opencv `pkg-config --cflags --libs opencv`