Opencv in ubuntu 20.04 undefined reference [closed]
I upgraded my PC to Ubuntu 20.04 and I installed OpenCV 4.2.0 which compiles correctly but when I try to compile a program that depends on it it gives me an error:
> undefined reference to `cv::imwrite(std::__cxx11::basic_string<char, std::char_traits<char>,../utils/aruco_test.cpp: In function ‘int main(int, char**)’:
.../utils/aruco_test1.cpp:324:21: warning: unused variable ‘optierro’ [-Wunused-variable]
int optierro = 6;
^~~~~~~~
std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
/usr/bin/ld: ../src/libaruco.so.3.0.12: undefined reference to `cv::imshow(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
/usr/bin/ld: ../src/libaruco.so.3.0.12: undefined reference to `cv::waitKey(int)'
I'm trying to compile ArUco from source which worked on my previous machine with ubuntu 16.04.
First I used the gcc version installed by default gcc-8 (for both OpenCV and ArUco) and then gcc-7 and I get the same erros.
Does anyone know why is that happen?
means, you're somehow not linking to opencv_imgcodecs (where the code for imwrite() is)
can you show the whole cmdline you're using to compile/link it ?
you'll also need to link opencv_highgui
in the end, it seems, you're not linking to ANY opencv libs ?
Usually I don't add opencv_highgui and opencv_imgcodecs manually but this time it has to be added I don't know why but it works now thank you!