Home –  Software – How to use dlib to QtCreator on Windows/Linux

How to use dlib to QtCreator on Windows/Linux

Dlib is a nice C++ library for machine learning that also includes some good implementation of computer  vision algorithm like the real-time pose estimation, that OpenCV strangely does not have.

Using Dlib is not so difficult, as is a "header-only" library and then you don't need to compile it. However, as it took me some time to figure out the correct steps to integrate it with OpenCV for Windows and Linux, I write this short post as a quick-rough guide to get it started.

Download Dlib and extract the folder somewhere. In windows, I used C:\, in Linux /home/username on Linux. Open Qt Creator and select "Qt Console Application". Once the files are generated, go to the .pro file of your project, and add

INCLUDEPATH += C:\dlib-18.18
LIBS+= -lgdi32 -lcomctl32 -luser32 -lwinmm -lws2_32

INCLUDEPATH += /home/<em>username</em>/dlib-18.18
LIBS += -pthread
CONFIG += link_pkgconfig

[extra libraries are required only for the gcc compiler, the others should add them automatically]

Then, right click on the "Sources" folder of your project, and select "Add Existing File", and add dlib-18.18/dlib/all/source.cpp

That's it! Now let's have some random dlib code and see if it works:

In main.cpp, add  #include <dlib/image_processing/frontal_face_detector.h> on top. Comment everything inside the main and add, instead

dlib::frontal_face_detector detector = dlib::get_frontal_face_detector();

this doesn't mean much, but it's just to try and see if it works. Now run qmake, and build everything. It should build without any error. You can run it, and use all the Dlib capability for your software.

2 thoughts on “How to use dlib to QtCreator on Windows/Linux

  1. Solo


    Can you explain how we can setup Dlib at QT creator for MAC os X sierra users ?

    I exhausted for half day to figure it out :(( . no luck...

    Dlib version : 19.8
    mac book pro sierra OSx

    also we have X11 path problem.. any idea ?

Leave a Reply

Your email address will not be published. Required fields are marked *