1

I want to compile easy programm in qt creator, but I have problems with opencv. Os- ubuntu 16.04 .pro file qt

LIBS += -lopencv_core -lopencv_imgproc -lopencv_highgui

Main program

#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <stdlib.h>
#include <stdio.h>

IplImage* image = 0;
IplImage* src = 0;

int main()
{
    char* filename = "Image0.jpg";
    image = cvLoadImage(filename,1);
    src = cvCloneImage(image);
    return 0;
}

Compilation error main.cpp:-1: error: undefined reference to `cvLoadImage'. What I am doing wrong?

3
  • What if you replace LIBS += ... with PKGCONFIG += opencv? Commented Jul 11, 2016 at 21:15
  • Since this is a QtCreator issue and has nothing at all to do with the Qt framework (not sure Qt is even used), I changed the tags. Commented Jul 11, 2016 at 21:18
  • PKGCONFIG += opencv didnt help. There is problem only with "cvLoadImage". Program compile normal,if i have remove this comand: char* filename = "Image0.jpg"; src = cvCloneImage(image) Commented Jul 11, 2016 at 21:23

1 Answer 1

1

It seems you're not linking against the OpenCV libraries correctly (or for some reason the linking is not working), the code itself is compiling.

Take a look at the answers to a similar question, that will most probably help you.

And by the way, cvLoadImage and IplImage are from the old C-API, avoid those. Use cv::Mat img=cv::imread("img.png"), instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.