Enabling C++11 in Qt Creator

I'm trying Qt Creator out, and had some dificulty figuring out how to enable C++11 support.qt_creator

After all, the best way to lear how to use the new features is to, well, to use them (and hopefully learn from the mistakes I will make).

After some research, and a couple of forum posts and stackoverflow answers, I finally managed to get it working.

It was simple, really. At least after knowing what had to be done.

Here's how you can do it.

Make sure your .pro file contains the following options:

LIBS += -stdlib=libc++
QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11

And now for the “tricky” part.My current development machine is a Mac.Also, Clang needs libc++ to support c++11. Apparently that requires Mac OS X 10.7 or later. And Qt creator was insisting in passing the -mmacosx-version-min=10.6 flag to the compiler.To override it, also add the following to the .pro file:

QMAKE_CXXFLAGS += -mmacosx-version-min=10.7
QMAKE_LFLAGS += -mmacosx-version-min=10.7

And that should do it!


Rui Pires

Working as a professional full time remote developer from the Azores since 2011.

Read More