Results 1 to 7 of 7

Thread: How can I use C++11?

  1. #1
    Join Date
    Mar 2011
    Posts
    29
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How can I use C++11?

    Well, actually my question is what do I need to use the latest version of MinGW with Qt Creator (if necessary Qt Creator 2.5 beta)?
    I have tried to do it myself but I cannot make it work.
    GCC 4.4 is supposed to support some of the new features but I cannot get the compiler to use them too.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How can I use C++11?

    What have you tried so far?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2011
    Posts
    29
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I use C++11?

    I have downloaded the latest version of Mingw and I have created a new tool chain in Qt Creator 2.5 and here I am stuck. I have no idea what to do next?

    I have also tried to use this option QMAKE_CXXFLAGS += -std=c++0x in Qt Creator 2.4 with the standard toolchains but it doesn't seem to enable the new language extensions in GCC 4.4 (Mingw).
    If I am not mistaken this type of declaration should be supported in GCC 4.4:
    Qt Code:
    1. auto doSomething(int a) -> int
    2. {
    3. return a;
    4. }
    To copy to clipboard, switch view to plain text mode 

    but it doesn't work.

    Or maybe it is necessary to compile Qt with Mingw 4.6 to be able to use it?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How can I use C++11?

    Can you see the "-stc=c++0x" part in the invocation of the compiler while you are building a project?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Mar 2011
    Posts
    29
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I use C++11?

    Yes, I do.

    This is the error I get when I use that option. QMAKE_CXXFLAGS += -std=c++0x

    21:40:12: Running build steps for project untitled3...
    21:40:12: Configuration unchanged, skipping qmake step.
    21:40:12: Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
    C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Debug
    mingw32-make.exe[1]: Entering directory `C:/Users/isto/Documents/QtMobile/untitled3-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK__Debug'
    g++ -c -std=c++0x -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -I"..\untitled3" -I"." -I"c:\QtSDK\Desktop\Qt\4.8.0\mingw\mkspecs\win32-g++" -o debug\main.o ..\untitled3\main.cpp
    In file included from c:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/postypes.h:42,
    from c:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/iosfwd:42,
    from c:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/ios:39,
    from c:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/ostream:40,
    from c:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/iostream:40,
    from ..\untitled3\main.cpp:1:
    c:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:159: error: '::swprintf' has not been declared
    c:\qtsdk\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cwchar:166: error: '::vswprintf' has not been declared
    mingw32-make.exe[1]: Leaving directory `C:/Users/isto/Documents/QtMobile/untitled3-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK__Debug'
    mingw32-make.exe[1]: *** [debug/main.o] Error 1
    mingw32-make.exe: *** [debug] Error 2
    21:40:13: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
    Error while building project untitled3 (target: Desktop)
    When executing build step 'Make'

  6. #6
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How can I use C++11?

    If i remember correctly MingW 4.4 doesn't implement lambda's, so you need to install a newer version of compiler.
    Here is the "0x status" for g++ (i guess the versions should match - in that case you need 4.5 for lambda functions)

  7. #7
    Join Date
    Mar 2011
    Posts
    29
    Thanked 3 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I use C++11?

    It doesn't really matter. If I add QMAKE_CXXFLAGS += -std=c++0x to the .pro file and even if I just have this:

    Qt Code:
    1. #include <QCoreApplication>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5. QCoreApplication a(argc, argv);
    6.  
    7. return a.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 

    UPDATE: This thread http://qt-project.org/forums/%20/viewthread/6731 suggest to use -std=gnu++0x instead of -std=c++0x and now the above code compiles without any errors or warnings. That's with the built-in MinGW compiler.

    So do I need to compile Qt now to use it with MingGW 4.6?

    How long would it take to compile it on a mobile i5 with 3Gb RAM?
    Last edited by Zingam; 13th April 2012 at 09:57.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.