How can I add the std=c++11 flag to the .pro on Windows ??



  • Hi,

    I'm migrating a Qt project from linux to windows, I'm still trying compile some libs I'm going to need on windows, but I'm getting this error:

    C:\Qt\Qt5.5.1\Tools\mingw492_32\i686-w64-mingw32\include\c++\bits\c++0x_warning.h:32: error:
    #error This file requires compiler and library support for the ISO C++ 2011 standard. 
    This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
    
    #error This file requires compiler and library support for the \
    ^
    

    and this it's how I'm putting it in the .pro of my project

    QMAKE_CXXFLAGS += -std=c++11
    

    I wasn't getting this error in linux.

    it's there anyone to tell qt to use g++ and not gcc, I think this could be the problem since all my sources are .C extensions, so is it possible that the qmake it's compiling with gcc and not g++ ? Could this be causing the problem ??



  • @ACJH48 First of all, you should know that it's better to use msvc when it comes to Qt on Windows.
    If you still want to use MinGW you should avoid using the ones that you download as tool, they are often old, but instead download the latest version.
    And... if you are running in a 64-bit operating system, be aware that mingw won't help you much, you will have to use mingw-w64 instead.


  • Moderators

    @Minupi Sorry but this statement is just wrong:
    "if you are running in a 64-bit operating system, be aware that mingw won't help you much, you will have to use mingw-w64 instead"
    You can use 32bit binaries on a 64bit systems without any issues. So, it is not wrong to use 32bit compiler on a 64 bit system.


  • Moderators

    I recommend to use MinGW provided via Qt installer. This is the easiest way to have Qt with MinGW on Windows.
    For C++11 you can try "CONFIG += c++11" in your *.pro file



  • CONFIG += c++11

    I use it with MingW on Windows and have no problem.



  • @jsulm "won't help you much" does not mean "you can't run", of course you can, but you will be limited, as you can't use 64-bit features.


  • Moderators

    @Minupi You're only limited if you need 64bit for what ever reason (more than 2GB RAM on Windows for your application for example), if not I don't see any limitations. Or which features do you mean?



  • @jsulm There are additional security features applied to 64-bit applications that will help in attempts of attack.
    And from a performance perspective, it will rely on the application that he is creating, if the user is doing some kind of intensive tasks it might be a problem for him on the future.
    I'm kinda methodical and I prefer to do the right way and thinking about the future, as requirements always changes.



  • I try with

    CONFIG += c++11
    

    but I keep getting the same error


  • Qt Champions 2016

    @ACJH48 said:

    But did you remove this from your project:

    QMAKE_CXXFLAGS += -std=c++11
    

    Your compiler probably doesn't support C++11. If you use

    CONFIG += c++11
    

    qmake will deduce whether or not this is the case and will enable C++11 only if your compiler supports it, opposed to the case when you pass the flag directly to the compiler (with CXX flags).

    @jsulm said:

    if not I don't see any limitations. Or which features do you mean?

    The 64 bit architecture might (or may not) include additional registers and instructions compared to its 32 bit counterpart. While in most cases this improvement might be marginal, there are the cases where it's preferred to use 64 bit architecture. Although, I wouldn't go as far to say that it's wrong to use 32bit application on a 64bit system.



  • Thanks for all the help, I finally found a way to over come this problem, I did by changing the extension of the sources files, from .C to .cc, this fixed the problem.


Log in to reply
 

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