Important: Please read the Qt Code of Conduct -

Qt 5.0.0 - enable c++ 11 on Mac OSX

  • I'm trying to enable c++11 features in my Qt Creator.
    I Installed version 2.6.1 that came with the Qt 5.0.0 framework on Everything's running smoothly and I created various applications up till now without problems in regard to the compiler or Qt Creator. However, if I'm trying to enable c++11, my compiler fails at the make step.

    I'm trying to set up the following in my .pro file:
    @QMAKE_CXXFLAGS += -std=gnu++0x@

    and I tried the same with
    @QMAKE_CXXFLAGS += -std=c++0x@

    The compiler however parses the pro file and on build stops compiling instantly with the following error:
    @15:57:41: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project Emerald (kit: Desktop Qt 5.0.0 clang 64bit (SDK))
    When executing step 'Make'@

    Obviously, the compiler doesn't like what I did. Any clues why that is the case?

  • Moderators

    Which compiler version are you using? Stock Apple-GCC or MacPorts?

  • Clang. The Libraries and the Creator automatically used it when I installed them.

  • Moderators

    Wrong flag, clang is probably bailing out. Use this and make sure you are using the newest Command Line Tools available:
    QMAKE_CXXFLAGS += -std=c++11

    More info here: "link":

  • Moderators

    Btw, if you ever switch to G++ (I know it's not likely, clang is simply great), it uses the same flag from version 4.7 upwards.

  • Thanks for your time so far, but I'm afraid, this didn't help. After updating XCode and the command line tools, I still get the same result - the same error. No matter if I use c++0x or c++11 as flag.

  • More info:
    Changing the compiler doesn't solve the issue. Neither Clang, Nor GCC seem to acknowledge the c++11 (or 0x) flag and both throw the same error. The necessary compile output is there:

    cc1plus: error: unrecognized command line option "-std=c++11"
    make: *** [main.o] Error 1
    make: Leaving directory `/Users/Aerius/Documents/Qt Projects/Emerald/Emerald-build-Desktop_Qt_5_0_0_clang_64bit_SDK-Debug'
    10:57:05: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project Emerald (kit: Desktop Qt 5.0.0 clang 64bit (SDK))
    When executing step 'Make'@

    The issue is obviously this line:

    @cc1plus: error: unrecognized command line option "-std=c++11"@

    So obviously the compiler doesn't know how to use c++11, which slightly annoys me.

    However, digging deeper led me to the point where I believe my gcc version is outdated. gcc -v gives me version 4.2.1, which doesn't seem to support c++11. However that influences clang remains a mystery to me, but for now I'll try to update to a newer gcc version and see if this helps anything.

  • Moderators

    Use macports to get GCC 4.7. Apple is known to keep sticking to old versions of GCC. clang remains mysterious to me, too. I've got llvm 3.2 on my machine, which should have basic C++11 support already.

  • Right, so. After updating to GCC 4.8 I finally get to compile the flag (only with gcc though, mind you - clang still doesn't work), however, from then on the compiler doesn't like the #include <initializer_list> used in QList. There's a solution to that as well, however, it includes only building for osx 10.6 or later, which basically means, I'll stop here now.

    For future reference, if anyone has the same error: A discussion about the issue with the initializer_list can be found here:

    And a Bugtracking record can be found here:

    As of now, this issue is not solved.

    Thanks for taking your time with me, sierdzio, even if - in the end - I'll just stick to not using c++ 11 for now I reckon'.

  • Moderators

    Pleasure, and I've learned a bit myself, too :)

Log in to reply