Opencv in ubuntu 20.04 undefined reference [closed]

asked 2020-05-25 11:01:45 -0600

ROSpioneer gravatar image

updated 2020-05-25 11:11:55 -0600

supra56 gravatar image

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?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2020-05-26 03:08:20.588199

Comments

1

undefined reference

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 ?

imshow()

you'll also need to link opencv_highgui

in the end, it seems, you're not linking to ANY opencv libs ?

berak gravatar imageberak ( 2020-05-25 11:18:28 -0600 )edit

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!

ROSpioneer gravatar imageROSpioneer ( 2020-05-25 15:47:45 -0600 )edit