12

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.

Community
  • 1
  • 1
Lander
  • 3,369
  • 2
  • 37
  • 53
  • Please try adding `CONFIG += c++11`. I don't have access to osx so I cannot test it. – Ali Jul 29 '13 at 09:13
  • Your error is `requires OS X 10.7 or later` - what is you OS X version? Is it OS X 10.7 or later, as **required** by the project? – sashoalm Jul 29 '13 at 11:16
  • @Ali Ha! Wow... Can't believe it was that easy! Could you respond to this as an actual answer so I can give you proper credit? – Lander Jul 30 '13 at 02:29
  • @Lander I am glad it helped. Posted the comment as an answer. – Ali Jul 30 '13 at 06:45

1 Answers1

17

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?

Community
  • 1
  • 1
Ali
  • 56,466
  • 29
  • 168
  • 265