0

I have a program correctly compiling and working on a machine and I'm trying to run it on another similar machine: same OS (Debian Stretch), same related packages installed, and same version of opencv (libopencv-dev version: 2.4.9.1+dfsg-2). However, on the second machine, ld fails to link opencv highgui symbols:

$ g++ $(pkg-config --cflags opencv) SDLTest.c $(pkg-config --libs opencv) -l pthread -L/usr/lib/x86_64-linux-gnu -lSDL
-I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -O3 /tmp/ccbTuxi1.o : Dans la fonction « opencv_calibrate(cv::VideoCapture) » :
SDLTest.c:(.text+0x33d3) : référence indéfinie vers « cv::namedWindow(std::string const&, int) »
SDLTest.c:(.text+0x3416) : référence indéfinie vers « cv::setMouseCallback(std::string const&, void (*)(int, int, int, int, void*), void*) »
SDLTest.c:(.text+0x3570) : référence indéfinie vers « cv::imshow(std::string const&, cv::_InputArray const&) »
SDLTest.c:(.text+0x36e0) : référence indéfinie vers « cv::destroyWindow(std::string const&) » collect2: error: ld returned
1 exit status

All corresponding packages are installed (libopencv-* and libhighgui-*). ldconfig finds the .so file:

$ sudo ldconfig -v 2>/dev/null | grep highgui   libopencv_highgui.so.2.4
-> libopencv_highgui.so.2.4.9

and the file exists:

$ locate libopencv_highgui.so.2.4.9
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so.2.4.9

There are many references to opencv throughout the code, but for some reason the highgui functions are the only one to create trouble.

In my code, I include the C headers (which for some reason work for including the C++ API):

#include <cv.h>
#include <cvaux.h>
#include <highgui.h>

and using the C++ headers instead does not change anything.

I'm out of ideas. Any idea?

Edit: Output of pkg-config --libs opencv:

/usr/lib/x86_64-linux-gnu/libopencv_calib3d.so -lopencv_calib3d /usr/lib/x86_64-linux-gnu/libopencv_contrib.so -lopencv_contrib /usr/lib/x86_64-linux-gnu/libopencv_core.so -lopencv_core /usr/lib/x86_64-linux-gnu/libopencv_features2d.so -lopencv_features2d /usr/lib/x86_64-linux-gnu/libopencv_flann.so -lopencv_flann /usr/lib/x86_64-linux-gnu/libopencv_gpu.so -lopencv_gpu /usr/lib/x86_64-linux-gnu/libopencv_highgui.so -lopencv_highgui /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so -lopencv_imgproc /usr/lib/x86_64-linux-gnu/libopencv_legacy.so -lopencv_legacy /usr/lib/x86_64-linux-gnu/libopencv_ml.so -lopencv_ml /usr/lib/x86_64-linux-gnu/libopencv_objdetect.so -lopencv_objdetect /usr/lib/x86_64-linux-gnu/libopencv_ocl.so -lopencv_ocl /usr/lib/x86_64-linux-gnu/libopencv_photo.so -lopencv_photo /usr/lib/x86_64-linux-gnu/libopencv_stitching.so -lopencv_stitching /usr/lib/x86_64-linux-gnu/libopencv_superres.so -lopencv_superres /usr/lib/x86_64-linux-gnu/libopencv_ts.so -lopencv_ts /usr/lib/x86_64-linux-gnu/libopencv_video.so -lopencv_video /usr/lib/x86_64-linux-gnu/libopencv_videostab.so -lopencv_videostab
Perdu
  • 187
  • 1
  • 6
  • What is the output of `pkg-config --libs opencv`? *but for some reason the highgui functions are the only one to create trouble* perhaps the compiler stopped because of too many errors. – Iharob Al Asimi Aug 26 '16 at 15:40
  • I added the output of pkg-config --libs opencv to the main post.I'm sure the mentioned functions are the problem, because if I remove related code, the program compiles and executes correctly. – Perdu Aug 26 '16 at 15:53
  • Are you sure those functions still exist in the version you're using? Add `-Wall -Werror` to your compilation command. Does it tell you about implicitly declared functions? – Iharob Al Asimi Aug 26 '16 at 16:20
  • I had some errors that I fixed, but none related to implicitly declared functions, and I still have the same linker errors in the end – Perdu Aug 29 '16 at 11:57

1 Answers1

0

So, I ended up fixing this by compiling opencv myself, with QT support.

Perdu
  • 187
  • 1
  • 6