I'm trying compile the simple code with C++ OpenCV but the both compilers g++ and clang++ accuse of undefined reference. I followed this steps for install OpenCV and run the last step (the tests) with success. My System: Ubuntu 18.04
- The simple code to teste compilation:
#include <opencv2/core.hpp>
int main(){
cv::Mat image;
}
- Output for g++ with command
g++ teste.cpp -o teste -I /usr/local/include/opencv4
:
/tmp/ccqJeAzC.o: In function `cv::Mat::~Mat()':
teste.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'
/tmp/ccqJeAzC.o: In function `cv::Mat::release()':
teste.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
- Output for clang++ with command
clang++ teste.cpp -o teste -I /usr/local/include/opencv4
:
/tmp/teste-44c531.o: In function `cv::Mat::~Mat()':
teste.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD2Ev]+0x47): undefined reference to `cv::fastFree(void*)'
/tmp/teste-44c531.o: In function `cv::Mat::release()':
teste.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x48): undefined reference to `cv::Mat::deallocate()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)