Poirot_ 2016-11-21 12:22 采纳率: 33.3%
浏览 3478

请教:尝试opencv2.4.13在linux下编译程序的报错

源代码:#include

#include

#include

using namespace cv;

int main()

{

VideoCapture cap(0);
if(!cap.isOpened())

{

return -1;

}

Mat frame;

bool stop = false;

while(!stop)

{

cap.read(frame);

imshow("Video",frame);

if(waitKey(30)==27) //Esc键退出

{

stop = true;

}

}

return 0;

}

报错:~$ g++ -o opencvq opencv.cpp
/tmp/ccQJKVIi.o: In function main':
opencv.cpp:(.text+0x29): undefined reference to
cv::VideoCapture::VideoCapture(int)'
opencv.cpp:(.text+0x38): undefined reference to cv::VideoCapture::isOpened() const'
opencv.cpp:(.text+0x80): undefined reference to
cv::VideoCapture::read(cv::Mat&)'
opencv.cpp:(.text+0xf9): undefined reference to cv::Mat::ones(cv::Size_<int>, int)'
opencv.cpp:(.text+0x146): undefined reference to
cv::VideoCapture::read(cv::Mat&)'
opencv.cpp:(.text+0x33d): undefined reference to cv::_OutputArray::_OutputArray(cv::Mat&)'
opencv.cpp:(.text+0x356): undefined reference to
cv::_InputArray::_InputArray(cv::Mat const&)'
opencv.cpp:(.text+0x36f): undefined reference to cv::_InputArray::_InputArray(cv::Mat const&)'
opencv.cpp:(.text+0x3a1): undefined reference to
cv::addWeighted(cv::_InputArray const&, double, cv::_InputArray const&, double, double, cv::_OutputArray const&, int)'
opencv.cpp:(.text+0x3ba): undefined reference to cv::_InputArray::_InputArray(cv::Mat const&)'
opencv.cpp:(.text+0x3fd): undefined reference to
cv::imshow(std::string const&, cv::_InputArray const&)'
opencv.cpp:(.text+0x425): undefined reference to cv::waitKey(int)'
opencv.cpp:(.text+0x489): undefined reference to
cv::VideoCapture::~VideoCapture()'
opencv.cpp:(.text+0x51a): undefined reference to cv::VideoCapture::~VideoCapture()'
/tmp/ccQJKVIi.o: In function
cv::Mat::~Mat()':
opencv.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to cv::fastFree(void*)'
/tmp/ccQJKVIi.o: In function
cv::Mat::release()':
opencv.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x47): undefined reference to cv::Mat::deallocate()'
/tmp/ccQJKVIi.o: In function
cv::Mat::operator()(cv::Rect_ const&) const':
opencv.cpp:(.text._ZNK2cv3MatclERKNS_5Rect_IiEE[_ZNK2cv3MatclERKNS_5Rect_IiEE]+0x27): undefined reference to `cv::Mat::Mat(cv::Mat const&, cv::Rect_ const&)'
collect2: error: ld returned 1 exit status

第一次使用,在此请教各位前辈,谢谢了

  • 写回答

1条回答

  • ImportSUC 2016-11-21 12:53
    关注

    缺少头文件,编译的时候没有导入依赖库

    评论

报告相同问题?

悬赏问题

  • ¥15 Labview机器人问题
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr