Click here to Skip to main content
15,884,006 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i will open the image using opencv + qt. but i have error like this :

mainwindow.obj:-1: error: LNK2019: unresolved external symbol _cvLoadImage referenced in function "private: void __thiscall MainWindow::openImage(void)" (?openImage@MainWindow@@AAEXXZ)

this code that i'm build it :

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <opencv/highgui.h>
#include <opencv/cv.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/mat.hpp>
#include <opencv2/objdetect/objdetect.hpp>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}
using namespace cv;
using namespace std;

MainWindow::~MainWindow()
{
    setAttribute(Qt::WA_QuitOnClose);
    delete ui;
}
void MainWindow::openImage ()
{
    fileName = QFileDialog::getOpenFileName(this,tr("Open Image"),
                                            QDir::currentPath(),
                                            tr("Image Files [ *.jpg , *.jpeg , *.bmp , *.png , *.gif]"));
    charFileName = fileName.toLocal8Bit().data();
    iplImg = cvLoadImage(charFileName);

    qimgNew = QImage((const unsigned char*)iplImg->imageData,iplImg->width,iplImg->height,QImage::Format_RGB888).rgbSwapped();
    ui->PictureOriginal->setPixmap(QPixmap::fromImage(qimgNew));

}


void MainWindow::on_OpenImage_clicked()
{
    openImage();
}
Posted
Comments
Richard MacCutchan 7-May-14 11:27am    
Have you included the opencv libraries in your project?
dimas92 7-May-14 11:51am    
yeah.. i did. i'm included in specific folder
Sayan Bera 7-May-14 13:10pm    
Have you added the path of the library folder in project properties->Linker->Additional Library Directories and added the .lib in Linker->Input->Additional Dependencies?
dimas92 7-May-14 13:52pm    
in default installed using cmake i put in
C:\OpenCV2.2\lib
but i put this lib in this director too :
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib

and in file.pro i add this too
LIBS += -LC:\\OpenCV2.2\\lib\
-lopencv_calib3d220d.lib\
-lopencv_contrib220d.lib\
-lopencv_core220d.lib\
-lopencv_features2d220d.lib\
-lopencv_ffmpeg220d.lib\
-lopencv_flann220d.lib\
-lopencv_gpu220d.lib\
-lopencv_highgui220d.lib\
-lopencv_imgproc220d.lib\
-lopencv_legacy220d.lib\
-lopencv_ml220d.lib\
-lopencv_objdetect220d.lib\
-lopencv_video220d.lib


still any wrong??
Richard MacCutchan 7-May-14 13:11pm    
Well you need to double check, because the linker definitely cannot find it.

1 solution

here is the problem:

iplImg = cvLoadImage(charFileName);


this function isnt resolved. I guess the lib isnt included

The opencv forum may better help you:

http://answers.opencv.org/question/22804/undefined-reference-to-cvloadimage/[^]
 
Share this answer
 
Comments
dimas92 10-May-14 13:17pm    
okay.. i read it. but that included in opencv 2.2 version??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900