我想在Eclipse Neon for C ++中使用OpenCV。不幸的是,在构建项目时存在一些链接错误。
我按照this教程并通过了以下步骤:
安装Eclipse Neon for C / C ++(Windows 64位)http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/neon1a
在文件夹C:\ MinGW
在Windows C:\ opencv
在eclipse中创建一个新的空C ++项目
添加教程
添加没有出现任何错误的源文件Test.cpp
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
Mat im = imread(argc == 2 ? argv[1] : "lenna.png", 1);
if (im.empty())
{
cout << "Cannot open image!" << endl;
return -1;
}
imshow("image", im);
waitKey(0);
return 0;
}
构建项目会返回以下错误:
19:00:45 **** Incremental Build of configuration Release for project OpenCV ****
Info: Internal Builder is used for build
g++ "-IC:\\opencv\\build\\include" -O3 -Wall -c -fmessage-length=0 -o Test.o "..\\Test.cpp"
g++ "-LC:\\opencv\\build\\x64\\vc12\\lib" "-LC:\\opencv\\build\\x64\\vc14\\lib" -o OpenCV.exe Test.o -lopencv_world310
Test.o:Test.cpp:(.text$_ZN2cv6StringC1EPKc[__ZN2cv6StringC1EPKc]+0x2d): undefined reference to `cv::String::allocate(unsigned int)'
Test.o:Test.cpp:(.text$_ZN2cv3MatD1Ev[__ZN2cv3MatD1Ev]+0x15): undefined reference to `cv::Mat::deallocate()'
Test.o:Test.cpp:(.text$_ZN2cv3MatD1Ev[__ZN2cv3MatD1Ev]+0x6d): undefined reference to `cv::fastFree(void*)'
Test.o:Test.cpp:(.text.startup+0x4f): undefined reference to `cv::imread(cv::String const&, int)'
Test.o:Test.cpp:(.text.startup+0x56): undefined reference to `cv::String::deallocate()'
Test.o:Test.cpp:(.text.startup+0xc0): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
Test.o:Test.cpp:(.text.startup+0xc7): undefined reference to `cv::String::deallocate()'
Test.o:Test.cpp:(.text.startup+0xd3): undefined reference to `cv::waitKey(int)'
Test.o:Test.cpp:(.text.startup+0x134): undefined reference to `cv::String::deallocate()'
Test.o:Test.cpp:(.text.startup+0x161): undefined reference to `cv::String::deallocate()'
collect2.exe: error: ld returned 1 exit status
19:00:45 Build Finished (took 781ms)
哪里可以出错?
感谢您的帮助!