Installing OpenCV 2.4.9 + QT5 in Ubuntu


Today is a small how to install OpenCV + QT5 in linux Ubuntu. For those who doesn’t know what is OpenCV, you can check here. Briefly OpenCV is a library for real time image processing created by Intel. It’s free for use under BSD license.


Installing QT

QT is a multiplataform application framework  developed by Digia. Some plataforms supported are: Android, Embedde Linux, iOS, Windows, Windows CE, etc.

To install QT:


Compiling OpenCV

First of all we need to install some required packages

Now, we get OpenCV here and we save it in a directory that we’ll call opencv5.

By default this library will be installed in /usr/local/lib. If you want to see some cmake options, read CMakeLists.txt.

In order to be able to link the lib, we need to create a file opencv.conf in /etc/ with the following:

and then execute


Testing OpenCV

If you want to test if everything is OK, you can go to the directory ./build/bin and execute one of several tests like:


QT5 + OpenCV together

First start QTCreator, in command line type


Create a new console project




Select Desktop as platform and follow the wizard until the end.




Now we need to tell to QT where we installed the libs. To do that open the .pro file and add the path.

Let’s test it and check if everything is working properly. In our OpenCV “hello world”, we’ll just show an image, of course, lena. You need to copie it in your project in Debug folder if you are in debug or Release if you are in release mode.

Below is our “hello world” code.

Compile and run and if everything is perfect, we should have this image




In the next posts I’ll start to dig a little more in OpenCV. I hope you guys are enjoying as much as I do. Below some references where to read more.




Marcelo Jo

Marcelo Jo is an electronics engineer with 10+ years of experience in embedded system, postgraduate in computer networks and masters student in computer vision at Université Laval in Canada. He shares his knowledge in this blog when he is not enjoying his wonderful family – wife and 3 kids. Live couldn’t be better.


7 Responses to 'Installing OpenCV 2.4.9 + QT5 in Ubuntu'

  1. masoud says:

    Thanks for the notes!

    I copied / pasted the code as it is but the program crashes even before running the main() function…just a window named qtcreator_process_stub is opned and says PRess to close this window…

    I think it’s a seg-fault…do you have any idea?


  2. Weza says:

    Great tutorial Marcelo.

  3. Fernando Madrigal says:

    Can you help me? I’ve reproduced the the example, I have Qt5 OpenCV 2.4.9 and Ubuntu whit GCC 5.3 64 bits as you. When compiling doesn’t drop me any error, but when I run it, it craches at line 20 with that message:

    The inferior stoped because it recived a signal from the operating system.

    Signal Name: SIGSEGV
    Signal Meaning: Segmentation fault.

    By the way I have the image in the rigth place.

    Thank you for your help.

    • marcelojo says:

      It’s really a generic error of segmentation fault. It can be lots of things. Do you copy paste the entire code as it is?

  4. Hadi says:

    When I compile :

    :-1: error: skipping incompatible /usr/local/lib/ when searching for -lopencv_core
    :-1: error: cannot find -lopencv_core
    :-1: error: collect2: ld returned 1 exit status

    Please help me, whats wrong?

    • marcelojo says:

      Hello, I guess your opencv compilation was correct. After that did you do sudo ldconfig? You can test if opencv is ok as well as mentionned in the post.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.