opencv3.2在ubuntu16.04安装,测试程序错误分析

来源:互联网 发布:美工待遇 编辑:程序博客网 时间:2024/05/16 15:52

opencv 在ubuntu中已经安装完毕,但是在测试一个程序中disp_image.cpp出现了错误

test.cpp:(.text+0x8b):对‘cv::imread(cv::String const&, int)’未定义的引用
test.cpp:(.text+0x10e):对‘cv::namedWindow(cv::String const&, int)’未定义的引用
test.cpp:(.text+0x163):对‘cv::imshow(cv::String const&, cv::_InputArray const&)’未定义的引用
test.cpp:(.text+0x18b):对‘cv::waitKey(int)’未定义的引用
/tmp/ccIfvETd.o:在函数‘cv::String::String(char const*)’中:
test.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x4d):对‘cv::String::allocate(unsigned long)’未定义的引用
/tmp/ccIfvETd.o:在函数‘cv::String::~String()’中:
test.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14):对‘cv::String::deallocate()’未定义的引用
/tmp/ccIfvETd.o:在函数‘cv::String::operator=(char const*)’中:
test.cpp:(.text._ZN2cv6StringaSEPKc[_ZN2cv6StringaSEPKc]+0x18):对‘cv::String::deallocate()’未定义的引用
test.cpp:(.text._ZN2cv6StringaSEPKc[_ZN2cv6StringaSEPKc]+0x48):对‘cv::String::allocate(unsigned long)’未定义的引用
/tmp/ccIfvETd.o:在函数‘cv::Mat::~Mat()’中:
test.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39):对‘cv::fastFree(void*)’未定义的引用
/tmp/ccIfvETd.o:在函数‘cv::Mat::operator=(cv::Mat const&)’中:
test.cpp:(.text._ZN2cv3MataSERKS0_[_ZN2cv3MataSERKS0_]+0x115):对‘cv::Mat::copySize(cv::Mat const&)’未定义的引用
/tmp/ccIfvETd.o:在函数‘cv::Mat::release()’中:
test.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b):对‘cv::Mat::deallocate()’未定义的引用
collect2: error: ld returned 1 exit status


分析:

错误中提示好像找不到库文件, 不过我也是加载了头文件和库文件,

g++ `pkg-config --cflags --libs  opencv` -o test test.cpp

测试  pkg-config --cflags --libs  opencv 也能输出包含头文件和库文件,

原来是在编译时的一个设置问题,要需要先编译再链接


g++ `pkg-config --cflags opencv` -o test test.cpp `pkg-config --libs opencv`
主要时刚接触opencv, linux的基础还很差, 以后需要加强学习


原创粉丝点击