【发布时间】:2016-05-23 06:32:28
【问题描述】:
我已经搜索了解决方案,但找不到任何解决方案。这对我来说仍然是新的,所以如果它是微不足道的,请原谅我。顺便说一下,我的操作系统是 Ubuntu 16.04。
我已经使用pyimagesearch 教程安装了与 Python 绑定的 OpenCV 3。我遇到过的最完整的 OpenCV 安装教程之一。因此,在使用 Python 和 OpenCV 很长一段时间后,我需要通过使用 OpenCV 和 C++ 来加强我的游戏。 我已经从site 复制并粘贴了用于加载和显示 C++ 图像的代码。然后,我用这个命令编译了我的程序:
g++ `pkg-config --cflags --libs opencv` test.cpp -o opencv
一开始,我收到了这个错误:
/usr/bin/ld: cannot find -lippicv
找到解决方案后(通过从opencv.pc 中删除-lippicv),我得到了这个输出:
/tmp/ccriaGtQ.o: In function `main':
test.cpp:(.text+0x9d): undefined reference to `cv::imread(cv::String const&, int)'
test.cpp:(.text+0x128): undefined reference to `cv::namedWindow(cv::String const&, int)'
test.cpp:(.text+0x17d): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
test.cpp:(.text+0x1a5): undefined reference to `cv::waitKey(int)'
/tmp/ccriaGtQ.o: In function `cv::String::String(char const*)':
test.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x4d): undefined reference to `cv::String::allocate(unsigned long)'
/tmp/ccriaGtQ.o: In function `cv::String::~String()':
test.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
/tmp/ccriaGtQ.o: In function `cv::Mat::~Mat()':
test.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'
/tmp/ccriaGtQ.o: In function `cv::Mat::operator=(cv::Mat const&)':
test.cpp:(.text._ZN2cv3MataSERKS0_[_ZN2cv3MataSERKS0_]+0x115): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
/tmp/ccriaGtQ.o: In function `cv::Mat::release()':
test.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
这快把我逼疯了。我仍然是这类事情的初学者。因此,任何帮助将不胜感激。
谢谢。
【问题讨论】:
-
你可以试试
g++ test.cpp -o opencv `pkg-config --cflags --libs opencv` -
@ManthanTilva 我真傻。谢谢!它有效!