1

First of all I know this question has been asked (see here) but those solutions did not work for me.

I am trying to install opencv to use with Qt Creator on ubuntu 14.04.

I followed this tutorial exactly and confirmed that it worked by running the facedetect example.

I then started on this tutorial for using Qt creator with opencv. I followed the steps in the video exactly, however when I build and run the example I get the following errors:

   /usr/bin/ld: cannot find -lopencv_core
   /usr/bin/ld: cannot find -lopencv_imgcodecs
   /usr/bin/ld: cannot find -lopencv_highgui

full compile output:

g++ -Wl,-rpath,/home/tpst/Program_Files/Qt-5.3.1/5.3/gcc_64 -Wl,-rpath,/home/tpst/Program_Files/Qt-5.3.1/5.3/gcc_64/lib -o test main.o   -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui -L/home/tpst/Program_Files/Qt-5.3.1/5.3/gcc_64/lib -lQt5Core -lpthread 
/usr/bin/ld: cannot find -lopencv_core
/usr/bin/ld: cannot find -lopencv_imgcodecs
/usr/bin/ld: cannot find -lopencv_highgui
collect2: error: ld returned 1 exit status
make: *** [test] Error 1
23:02:50: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project test (kit: Desktop Qt 5.3 GCC 64bit)
When executing step 'Make'

And here is the contents of my .pro file:

QT       += core

QT       -= gui

TARGET = test
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app

INCLUDEPATH += /usr/local/include/opencv
LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui

SOURCES += main.cpp

I have also tried to compile using terminal and get the same (/usr/bin/ld: cannot find -llib)

I dont understand why Qt cant find the libraries. You can see that they exist in the directory here

Some help would be appreciated. I'm new to linux and Qt, I dont really understand the solutions posted to similar questions and have not been able to solve this myself.

Community
  • 1
  • 1
user2790954
  • 111
  • 2
  • 12
  • can you try to either rename or create links to your libs so that they are named like: `libopencv_calib3d.so` etc without the `.3.0`? – Micka Nov 10 '15 at 13:34

1 Answers1

2

afaik your linked libraries must look like libName.so but your libraries are named libName.so.version so the linker doesn't find them. Try to create symbolic links:

ln /usr/local/lib/libopencv_core.so.3.0.0 /usr/local/lib/libopencv_core.so
ln /usr/local/lib/libopencv_imgcodecs.so.3.0.0 /usr/local/lib/libopencv_imgcodecs.so
ln /usr/local/lib/libopencv_highgui.so.3.0.0 /usr/local/lib/libopencv_highgui.so
Micka
  • 19,585
  • 4
  • 56
  • 74
  • Thanks, this fixed my issue. Do you know why this would happen on my system and not on that of the guides I was following? – user2790954 Nov 10 '15 at 17:07
  • maybe those symbolic links are already present at some different location? did you compile opencv yourself? did you run the install routine too? you could however add the full file name to the linker somehow. – Micka Nov 10 '15 at 17:15