user3340703
user3340703

Reputation: 23

OpenCv Linking Issue

I'm using Kubuntu and have some Problems with linking OpenCv ( 2.4.6.1 ) Librarys ( I guess ).

So I've been using this tutorial http://karytech.blogspot.de/2012/05/opencv-24-on-ubuntu-1204.html and got the installation tested ok ( section: ./opencv_test_core ). Then I downloaded the testfile below but could make it work. Tried some other code always the same error:

g++ -L/usr/local/lib -lcv -lcxcore -lcvaux -lhighui -lm hello.cpp
/usr/bin/ld: cannot find -lcv
/usr/bin/ld: cannot find -lcxcore
/usr/bin/ld: cannot find -lcvaux
/usr/bin/ld: cannot find -lhighui
collect2: Fehler: ld gab 1 als Ende-Status zurück ( ld exit status is 1 )

( as for the strange library names in the tutorial i also tried -lopencv_calib3d ... )

then tried it in code::blocks and get this:

main.c undefined reference to cvGetRows

Headers are in /usr/local/include/opencv /usr/local/include/opencv2 Librarys are in usr/local/lib

( If that helps ):

$ pkg-config --cflags opencv
returns: -I/usr/local/include/opencv -I/usr/local/include  

$ pkg-config --libs opencv
returns: /usr/local/lib/libopencv_calib3d.so /usr/local/lib/libopencv_contrib.so ...

$ apt-cache search opencv
returns: opencv-doc - OpenCV documentation and examples
python-opencv - Python-Anbindungen für die OpenCV-Bibliothek
libavcodec-extra-53 - Libav codec library ...

Upvotes: 2

Views: 1222

Answers (1)

edmz
edmz

Reputation: 8494

To link against OpenCV, you have to pass g++ (which will run ld internally) where the libraries are (if they are not standard ones). You can do it manually, if you want to link only some of them. But the fastest way is to rely on pkg-config:

g++ faceDetect.cpp $(pkg-config --libs opencv --cflags)

However, in the package there's a Makefile, just cd the directory you've extracted that archive, and run make.

Upvotes: 3

Related Questions