opencv编译成功也安装成功了,最后make的时候提示缺少引用
如题,先说一下机子状态环境
一开始就转了opencv2,然后编译成功了也能够正常调用
后来改了一下gcc g++ 版本,从 5 改到4 ,在编译的时候就提示如下信息:
CMakeFiles/canny.dir/5-10-13.cpp.o: In function `main':
5-10-13.cpp:(.text+0x110f): undefined reference to `cv::imread(std::string const&, int)'
5-10-13.cpp:(.text+0x1204): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
5-10-13.cpp:(.text+0x1276): undefined reference to `cv::imread(std::string const&, int)'
5-10-13.cpp:(.text+0x13ca): undefined reference to `cv::namedWindow(std::string const&, int)'
5-10-13.cpp:(.text+0x1444): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
collect2: error: ld returned 1 exit status
CMakeFiles/canny.dir/build.make:119: recipe for target 'canny' failed
make[2]: *** [canny] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/canny.dir/all' failed
make[1]: *** [CMakeFiles/canny.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
说是找不到引用,真的莫名其妙,后来把gcc g++ 的版本改回来了就ok了,所以gcc g++ 版本更改谨慎,
另外,其实如果你在编译的时候有gcc 和 g++的版本需求,可以在cmakeList 中进行设置。