Important: Please read the Qt Code of Conduct -

Qt Creator & C++11

  • Hello

    I've tried to use Qt Creator with the latest version of C++. I installed the latest version of MinGW, added it to the Tool Chains of Qt Creator and selected it but I got the following error message:
    warning: identifier 'nullptr' is a keyword in C++11 [-Wc++0x-compat]

    I added argument "-std=c++0x" to the Build Steps arguments list and then I got this:
    :-1: error: invalid option -- =

    Now I have no idea what to do. Can you please help me?


    There seems to be a problem using my installed version of MinGW anyway. If I build my project using it (without C++11) I can't see any program window.

  • "-std=" is C++ compiler flag, so you have to give it to compiler which can be archived by adding
    QMAKE_CXXFLAGS += -std=c++11

    to your .pro-file.

    I don't know about your other problem but did application work before? Does it give some errors when starting?

  • Hi

    That helped. Thanks! However I'm wondering why I cannot put -std=c++11 to
    Projects -> Build Steps -> Make Details -> Make arguments

    EDIT: It seems that when I use the latest version of MinGW compiler downloaded from MinGW website the program can be compiled but the program window won't show up. This doesn't happen if I use the MinGW compiler shipped with Qt Creator. :/ And unfortunately that compiler does not support C++11.

  • Projects -> Build Steps -> Make Details -> Make arguments are arguments for make command which handles building from Makefile which is generated by qmake.
    If your application requires C++11 then it is better to define it in project file.

    Could your other problem be caused by Qt which is built with older MinGW?

  • I had the same set of problems. Mine were solved by add a qmake link flags setting. These are the two lines that made C++11 work with clang++ 3.1 for me

    QMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.6
    QMAKE_LFLAGS += -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.6

  • Should've verified that first. The correct flags are:
    QMAKE_CXXFLAGS = -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7
    QMAKE_LFLAGS = -std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7

  • thanks for: QMAKE_CXXFLAGS = -std=c+11

  • There is a much much easier way:

    @CONFIG += c++11@

    Put that in your project .pro file and you're done :)

Log in to reply