pkg-config can't find opencv

Clement Roblot picture Clement Roblot · Feb 27, 2013 · Viewed 27k times · Source

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.

Answer

doizuc picture doizuc · Jan 16, 2014

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.