C++ pkg-config 找不到 opencv
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15113753/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pkg-config can't find opencv
提问by Clement Roblot
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 :
我在 lubuntu 12.10 发行版上安装了 opencv。然后,当我尝试编译使用 opencv 的代码时,它说找不到它。所以我在终端中尝试:
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.
它回答我说找不到opencv。但是这些文件安装在 /usr/lib 中。我不明白为什么它找不到它们。
回答by doizuc
You have to put pkg-config --cflags --libs opencv
at the end of your g++ line. For example :
您必须放在pkg-config --cflags --libs opencv
g++ 行的末尾。例如 :
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.
不编译并且有未定义的引用。