当前位置: 代码迷 >> QT开发 >> error: collect2: ld returned 1 exit status 请帮 小弟我看看程序时哪里有有关问题
  详细解决方案

error: collect2: ld returned 1 exit status 请帮 小弟我看看程序时哪里有有关问题

热度:275   发布时间:2016-04-25 05:08:28.0
error: collect2: ld returned 1 exit status 请帮 我看看程序时哪里有问题
本人用qt creator 创建了一个gui application

MyTest.h

C/C++ code
#ifndef MYTEST_H#define MYTEST_H#include <QtGui/QWidget>#include <cv.h>#include <QImage>#include <QtCore>#include <highgui.h>class MyTest : public QWidget{    Q_OBJECTpublic:    MyTest(QWidget *parent = 0);    ~MyTest();    void showImage(char *filename);    QImage& pConvQImage(IplImage *p,QImage &q);private:    IplImage * pImage;    QImage qImage;};#endif // MYTEST_H



MyTest.cpp

C/C++ code
#include "mytest.h"#include <QPainter>MyTest::MyTest(QWidget *parent)    : QWidget(parent){    this->showImage("lena.jpg");}MyTest::~MyTest(){}void MyTest::showImage(char *filename){    pImage = cvLoadImage(filename,1);    QPainter q;    q.drawImage(this->rect(),pConvQImage(pImage,qImage));}QImage& MyTest::pConvQImage(IplImage *p, QImage &q){    q = QImage((const uchar*)p->imageData,p->width,p->height,p->widthStep,QImage::Format_RGB888);    return q;}



main.cpp

C/C++ code
#include <QtGui/QApplication>#include "mytest.h"int main(int argc, char *argv[]){    QApplication a(argc, argv);    MyTest w;    w.show();    return a.exec();}



test_OpenCV4.pro
C/C++ code
TARGET = test_OpenCV4TEMPLATE = appSOURCES += main.cpp\        mytest.cppHEADERS  += mytest.hINCLUDEPATH += D:\OpenCV2.0\include\opencv \    LIBS \    += \    D:\OpenCV2.0\lib



运行的时候就出现一个错误,但是找不到错误在哪里,请高手指点一二

Assembly code
D:/learning/workspace/test_OpenCV4/mytest.cpp:17: undefined reference to `cvLoadImage':-1: error: collect2: ld returned 1 exit status


------解决方案--------------------
pImage = cvLoadImage(filename,1);
没找到这个函数在那声明定义的,你自己再找找吧
------解决方案--------------------
重复的帖子...
http://topic.csdn.net/u/20100307/12/08f62883-7019-47eb-8767-899301027a43.html
  相关解决方案