简体   繁体   中英

pkg-config can't find opencv

I installed opencv on a lubuntu 12.10 distro. Then when I try to compile a code which is using opencv it says it can't find it. So I try in a terminal:

pkg-config --cflags --libs opencv

It answers me that it can't find opencv. But the files are installed in /usr/lib. I don't understand why it can't find them.

You have to put pkg-config --cflags --libs opencv at the end of your g++ line. For example :

g++ test.cpp -o test `pkg-config --cflags --libs opencv`

Compiles

g++ `pkg-config --cflags --libs opencv` test.cpp -o test

Doesn't compile and have undefined reference.

For OpenCV 4 you might have to use:

pkg-config --cflags --libs opencv4

(Note the 4 in the end!)

From OpenCV 4:

add -DOPENCV_GENERATE_PKGCONFIG=YES to cmake build arguments.

Use YES , ON is not working anymore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM