Qt Creator, MinGW and C++ 11.
-
wrote on 23 Jan 2012, 10:59 last edited by
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!
-
wrote on 23 Jan 2012, 16:01 last edited by
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.
-
wrote on 23 Jan 2012, 20:13 last edited by
Ok, Volker, many thanks for the help!
I will check it out tomorrow, when i go back to work, and report back.
Thanks again!
-
wrote on 24 Jan 2012, 06:37 last edited by
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.
-
wrote on 24 Jan 2012, 08:32 last edited by
@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!
@Lukas:
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!
-
wrote on 24 Jan 2012, 09:08 last edited by
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/.
-
wrote on 24 Jan 2012, 09:57 last edited by
Ok, i will try this TDM-GCC package that you proposed. Have you experiment any difficulties/problems with the debugger (gdb) so far ?
-
wrote on 24 Jan 2012, 10:20 last edited by
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.
-
wrote on 24 Jan 2012, 13:49 last edited by
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.
Anyway.
-
wrote on 3 May 2012, 19:26 last edited by
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.
-
wrote on 3 May 2012, 19:40 last edited by
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!