Using Boost C++ Libraries within QTCreator

In this earlier post, I showed how to use OpenCV from within QTCreator.  As I also use the boost c++ libraries, I will show you how to quickly use them within the QTCreator.

I love the boost libraries and I cannot live without them.  It is also very simple to use them in QTCreator.  First off, download the boost c++ libraries zip file from the link if you haven’t done so yet.  Then unzip the file somewhere like in your C:\ drive for example.  Then in your QTCreator project, in your .pro project file, just add the link to the boost include directory.

For example I unpacked the boost libraries to C:\boost_1_44_0 directory.  Thus, in my .pro project file, I added the following line to the file:

INCLUDEPATH += C:\boost_1_44_0
That’s it, you’re done.  Now you can use the boost libraries in your QTCreator project.

About Vincenzo Barbato

Known to his friends as Enzo, he's an outside-the-box engineer/researcher whose interests and expertise span many fields, including controls systems, multi-physics simulations, mechatronics, oil technologies, data analysis and machine vision just to name a few.

Refusing to grow up, he's on a continuous journey to develop simple and creative solutions that have the power of disrupting industries by optimizing systems and processes.

Married to a beautiful wife, with two beautiful daughters and two identical twin boys, his home is a never ending chaotic fountain of inspiration.

His outlook on life:

"Never blindly accept what you're told, listen, but then question, with curiosity, creativity and collaboration we can change the world"

About Enzo

Known to his friends as Enzo, he's an outside-the-box engineer/researcher whose interests and expertise span many fields, including controls systems, multi-physics simulations, mechatronics, oil technologies, data analysis and machine vision just to name a few. Refusing to grow up, he's on a continuous journey to develop simple and creative solutions that have the power of disrupting industries by optimizing systems and processes. Married to a beautiful wife, with two beautiful daughters and two identical twin boys, his home is a never ending chaotic fountain of inspiration. His outlook on life: "Never blindly accept what you're told, listen, but then question, with curiosity, creativity and collaboration we can change the world"

3 Comments

  1. Don’t forget to insert the necessary includes into your code.
    For example, if you’re using the boost::shared_ptr smart pointers, insert the line:
    #include <boost/smart_ptr/shared_ptr.hpp>

  2. my directory is C:\Qt\5.5\boost_1_58_0 but doesn’t work, and appear this messages

    C:\Qt\5.5\boost_1_58_0\boost\regex\v4\cpp_regex_traits.hpp:370: error: undefined reference to `boost::re_detail::cpp_regex_traits_char_layer::init()’

    my surce code is:

    #include
    #include
    #include

    using namespace std;

    int main(int argc, char *argv[])
    {

    boost::regex expresion( “J.*\\d[0-35-9]-\\d\\d-\\d\\d” );

    string string1 = “Jane cumple anios el 05-12-75\n”;

    return 0;
    }

    and my pro file is:

    QT += core

    QT -= gui

    TARGET = beggining
    CONFIG += console

    INCLUDEPATH += C:\Qt\5.5\boost_1_58_0

    TEMPLATE = app

    SOURCES += main.cpp

  3. Jose,

    The boost regex library is NOT a header-only library and therefore you’re gonna have to build (compile) it yourself.

    Here are the instructions from the boost regex library:

    http://www.boost.org/doc/libs/1_58_0/libs/regex/doc/html/boost_regex/install.html

Leave a Reply

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