Lander
Lander

Reputation: 3437

Can't use C++11 features when building with Qt

I'm on OS X 10.8.4 (Mountain Lion) with the latest command line tools from Xcode. I'm trying to build a Qt project (in Qt Creator) which uses some C++11 features; notably std::unique_ptr. Whenever I try building though, I get the following error:

clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later)

My .pro file is as follows:

QT       += core gui

QMAKE_CXXFLAGS += -mmacosx-version-min=10.7 -std=c++11 -stdlib=libc++
LIBS += -mmacosx-version-min=10.7 -stdlib=libc++

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = APPNAME
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui
cache()

I've tried the solutions presented in other answers (see here and the top answer here), neither of which seemed to work.

Upvotes: 12

Views: 3793

Answers (1)

Ali
Ali

Reputation: 58431

According to this site add

CONFIG += c++11

to your .pro file (see at the bottom of that web page). It requires Qt 5.


UPDATE: As for Qt 4, see How to enable C++11 in Qt Creator?

Upvotes: 17

Related Questions