How to use c++11 and boost in qt creator(boost library and qt library together in qt creator)?

  • Hello
    i want to use c++11 with qt library in qt creator...and i dont know how to use c++11 and boost library in qt creator.
    please some one tell me exactly how...
    tanx in adv;)

  • Moderators

    For C++11, add this to your qmake file:

    AFAIK, this is GCC flag, you might need to check if it works for other compilers, too.

    As for boost, just add headers to INCLUDEPATH, and libraries to LIBS variables in qmake, and it should work.

  • where is the qmake file?and how can i add something to it?
    i found a qmake fplder in my qt(instalation path),and it has alot of file to add(headers i think)...
    (im new in qt ,,and it was confusing me,,i need more help..plz help;)

  • Your qmake file is the .pro file. It can be accessed directly from the project tree in Qt Creator. The .pro file is the file describing your project.

  • Moderators

    Sorry, I should have typed more clearly. I meant the .pro file that you have in your project (if you use qmake. For cmake it's different). This file is parsed by qmake when you build your project.

  • @
    QMAKE_CXXFLAGS += -std=c++0x // for GCC < 4.7
    QMAKE_CXXFLAGS += -std=c++11 // for GCC >= 4.7

  • Moderators

    Ah, I'm living in the past :P Even though I'm using GCC 4.7.

  • thank u all a lot....
    but i have another question...
    i apologize from you all.
    that i have another problem...
    when i installing Qt libraries 4.8.2 for Windows (minGW 4.4, 318 MB) it says to me its need mingw 4.4 ..but i have mingw 4.7 ...when i choose the mingw4.7 it says to me that only version with w32api3.13 are supported ...
    how ever i instaled it and set the c:\mingw\bin in enviromentvariable....and do what you said ....
    but my simple code event dosent correctly work.....:

    Project created by QtCreator 2012-09-04T17:51:47

    #//QMAKE_CXXFLAGS +=-std=c++0x
    QMAKE_CXXFLAGS += -std=c++11
    QT += core

    QT -= gui

    TARGET = lllming
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp
    #include <QCoreApplication>
    using namespace std;
    int main(int argc, char *argv[])
    QCoreApplication a(argc, argv);
    return a.exec();
    program is gonna run but it crashed.....

    where is the mistake or do i have to set mingw in tool chain?(its auto detected,but i think it use vs2010 compiler as default ....

    [Edit: Added @ tags around code. Please use proper formatting. -- mlong]

  • Moderators

    Sadly, getting a proper mingw and setting it up correctly is a very painful process. If you have access to MSVC, use it, will be easier and less frustrating. If you really need mingw, the easiest option is to install the Nokia Qt SDK, wich provides it's own mingw copy that is known to work.

  • the msvc problem is ,it doesnt supprot c++11..and i want to use c++ 11...becuase c++ and boost have some thing better than qt library like thread in c++ 11 is much easy and use full than thread in qt(it is in qt very confusing and not good at all,,,)...

  • [quote author="friendchp" date="1346838180"]when i choose the mingw4.7 it says to me that only version with w32api3.13 are supported ...[/quote]
    You can't use a prebuilt Qt. You will have to build Qt on your own using GCC 4.7.

  • seriously?
    i really dont know how to do that ...
    i download the qt-creator-2.5.1-src code from qt ...
    plz help me...
    (tanx alot in adv to u all;) )

  • [quote author="friendchp" date="1346875161"]seriously?[/quote]Seriously. GCC 4.4 is not binary compatible with GCC 4.7. This is the reason you have different packages for MSVC2005, MSVC2008 and MSVC2010, as they aren't binary compatible as well.

    [quote author="friendchp" date="1346875161"]i really dont know how to do that ... i download the qt-creator-2.5.1-src code from qt ...[/quote]You need to build Qt, not Qt Creator.

    Building Qt isn't that difficult. Just grab the desired "mingw":, "git": and "perl": package.

    git clone git:// & cd qt

  • Moderators

    [quote author="Lukas Geyer" date="1346911052"]

    git clone git:// & cd qt
    Step #2 is a little different for MinGW/MSYS, actually. Make sure you call 'configure.exe', not 'configure' (they're different files)

  • [quote author="JKSH" date="1346932867"]Step #2 is a little different for MinGW/MSYS, actually[/quote]
    Not if you are building from the Windows command line.

  • i installed the activeperl ,msisgit
    and download the mingw( from where u told me)...
    i typed git clone git:// & cd qt
    in git-cmd.bat....
    and it doing this right now:

    C:\Users\FriendChp>git clone git:// & cd qt
    Cloning into 'qt'...
    remote: Counting objects: 666833, done.
    remote: Compressing objects: 100% (150956/150956), done.
    Receiving objects: 3% (24271/666833), 6.68 MiB | 25 KiB/s

    am i right in this scope?
    do i have to copy mingw( that i downloaded )in mingw folder in msysgit directory(before type those instruction in git-cmd.bat) ?
    tanx in adv;)

  • Yes, as soon as git has finished cloning into qt.git you are ready to configure and build Qt.

    Just make sure mingw\bin and perl\bin is in %PATH%.

  • thanx alot to u all for your guide.
    finally i build it...
    (soorry for this question)
    and now can i use it? to use this library ?its size is almost 6gig.
    how to use it in qt creator? qt creator now using the vs compiler for to change it?
    (i set the qmake (in this builing the library) in qt....and for compile time it say an error :
    Error while building/deploying project future (target: Desktop)
    When executing step 'qmake')
    plz help...

  • There are lots of question in ur mind......
    Please read carefully how to work with "MAKEFILE", it is very important for building any library/app.

    1. configure
    2. make
    3. install
    4. clean or delete src
    5. setup environment according to insatllation
    6. use it

  • any help,please?

  • Well, if your library is 6 GB in size definitly something went wrong. The debug libraries should be between 50 MB and 200 MB, the release libraries between 3 MB and 10 MB.

    If you have a working library set you will have to add your compiler to the toolchains section and Qt itself to the Qt versions (depending on your Qt Creator version) section.

Log in to reply