pkg-config can't find opencv

一笑奈何 提交于 2021-02-07 06:24:56

问题


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.


回答1:


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.




回答2:


For OpenCV 4 you might have to use:

pkg-config --cflags --libs opencv4

(Note the 4 in the end!)



来源:https://stackoverflow.com/questions/15113753/pkg-config-cant-find-opencv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!