Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I add the std=c++11 flag to the .pro on Windows ??

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

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 5 Posters 6.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ACJH48
    wrote on last edited by A Former User
    #1

    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 ??

    ? 1 Reply Last reply
    0
    • A ACJH48

      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 ??

      ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      @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.

      jsulmJ 1 Reply Last reply
      0
      • ? A Former User

        @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.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @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.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        ? 1 Reply Last reply
        0
        • jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • W Offline
            W Offline
            wqking
            wrote on last edited by
            #5

            CONFIG += c++11

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

            My personal website https://www.kbasm.com/
            My Github https://github.com/wqking

            1 Reply Last reply
            0
            • jsulmJ jsulm

              @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.

              ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              @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.

              jsulmJ 1 Reply Last reply
              0
              • ? A Former User

                @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.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by jsulm
                #7

                @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?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                ? 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @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?

                  ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  @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.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    ACJH48
                    wrote on last edited by
                    #9

                    I try with

                    CONFIG += c++11
                    

                    but I keep getting the same error

                    kshegunovK 1 Reply Last reply
                    0
                    • A ACJH48

                      I try with

                      CONFIG += c++11
                      

                      but I keep getting the same error

                      kshegunovK Offline
                      kshegunovK Offline
                      kshegunov
                      Moderators
                      wrote on last edited by kshegunov
                      #10

                      @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.

                      Read and abide by the Qt Code of Conduct

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        ACJH48
                        wrote on last edited by
                        #11

                        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.

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved