[英]pkg-config can't find opencv
I installed opencv on a lubuntu 12.10 distro.我在 lubuntu 12.10 发行版上安装了 opencv。 Then when I try to compile a code which is using opencv it says it can't find it.
然后,当我尝试编译使用 opencv 的代码时,它说找不到它。 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.它回答我找不到 opencv。但是这些文件安装在 /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.您必须将
pkg-config --cflags --libs opencv
放在 g++ 行的末尾。 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:对于 OpenCV 4,您可能必须使用:
pkg-config --cflags --libs opencv4
(Note the 4 in the end!) (注意最后的4!)
From OpenCV 4:来自 OpenCV 4:
add -DOPENCV_GENERATE_PKGCONFIG=YES
to cmake build arguments.将
-DOPENCV_GENERATE_PKGCONFIG=YES
添加到 cmake 构建 arguments。
Use YES
, ON
is not working anymore.使用
YES
, ON
不再工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.