Qt Creator, MinGW and C++ 11.

  • Hi to all!

    I am using Qt Creator 2.4.0 on Windows 7 32bits and MinGW as the compiler (the one that came with Qt installer program). I am trying to use some features of C++ like "auto" and lambdas with no (compile) success.

    Is there a switch that i have to pass to the compiler so to be able to compile this stuff ?

    Thanks a lot for any help!

  • add to your .pro file:

    QMAKE_CXXFLAGS += -std=gnu++0x

    Have a look at "this older thread":/forums/viewthread/6731 too. The tag search on c++0x should give you some additional infos too.

  • Ok, Volker, many thanks for the help!

    I will check it out tomorrow, when i go back to work, and report back.

    Thanks again!

  • C++11 support in MinGW 4.4 is mediocre, at best. Prepare for a lot of unsupported stuff and compiler crashes. I strongly advise to upgrade to a recent GCC / MinGW version.

  • @Volker:
    It (somewhat) works now. For example, the "auto" is now recognized but a line such as this:
    [] { cout << "Hello, my friends"; }();

    does not compile. So it seems that it "doesn't know" about lambdas!

    You have absolutely right...
    My Qt installer, set up compiler stuff at C:\QtSDK\mingw\bin, where i can see gcc.exe and ming32-gcc.exe (among other files) both at version 4.4.0.

    Do you think i should wait for Qt-Updater to update my installation to a more recent versions of the compiler or should (can) i do it myself without mess up anything ?

    Thank you both for the help!

  • I'm unaware of any plans of upgrading MinGW in the Qt SDK (please correct me if I'm wrong). I either would switch to MSVC2010 (the compiler that comes with the express edition can be used to create commercial applications at no cost as well) or a recent version of MinGW, like "TDM-GCC":http://tdm-gcc.tdragon.net/ or "MinGW-w64":http://mingw-w64.sourceforge.net/.

  • Ok, i will try this TDM-GCC package that you proposed. Have you experiment any difficulties/problems with the debugger (gdb) so far ?

  • To be honest I've switched to MSVC2010 and it is quite a while since I used TDM-GCC, but feel free to come back if you experience any issues.

  • Hmm..i installed TDM-GCC and get the up-to-date MinGW stack and now, there is no way i can make GDB work again from inside Creator..."Executable failed. During startup program exited with code 0x0"

    I cannot understand why C++ dev-stack is so complicated to setup correctly, at least on Windows.


  • I tried
    @QMAKE_CXXFLAGS += -std=c++0x@

    and also tried
    @QMAKE_CXXFLAGS += -std=gnu++0x@

    in my projects, with the Qt 4.8.0 and Qt 4.8.1 on Windows 7 (64-bit). Both were using mingw4.4.

    I get segmentation faults during the compile.

  • Sorry for the almost immediate second post - I downloaded QtCreator 2.5 RC, and used the MinGW 4.6.2 that comes bundled with it. Everything compiled and ran!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.