QT can't find openCV's libs

前端 未结 2 1633
孤街浪徒
孤街浪徒 2021-01-23 14:59

I\'ve installed OpenCV via this instruction.

I use OpenCV when and build the code via cmake - and it\'s all ok. But now I\'m trying to use OpenCV from QT, and I get err

2条回答
  •  有刺的猬
    2021-01-23 15:34

    You are getting a linker error, so the compilation is correct. In order to add correctly the linking library directories and the linking libraries to your .pro file you should issue a command like this at the console:

    username@linux-host:~> echo $(pkg-config --libs opencv)

    You should then read a long list of libraries as in the following line:

    -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_ocl -lopencv_photo -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videostab /usr/lib64/libXext.so /usr/lib64/libX11.so /usr/lib64/libICE.so /usr/lib64/libSM.so /usr/lib64/libGL.so /usr/lib64/libGLU.so -lrt -lpthread -lm -ldl

    After you have obtained this long sequence of strings with all the libraries and the options, insert it in the .pro file like this:

    LIBS += -lopencv_calib3d -l... ...insert all the strings as seen above!

    Save the .pro file, re-run qmake and run make again. The linking error should have disappeared.

    If the problem is not disappeared or if other linking errors are shown, find all the files with the extension .pc in your opencv compilation directory (and subdirectories) and copy them as root in the directory /usr/share/pkgconfig/

    Then issue again the command above and insert in the .pro file the correct sequence of strings that identify the library options in the LIBS += line and save the .pro file, re-run qmake and re-run make.

提交回复
热议问题