Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
433 views
in Technique[技术] by (71.8m points)

c++ - How to specify target mac os x version using qmake

I am trying to compile c++11 code on the Mac OS X using Qt Creator/qmake and I am getting the following error:

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

When I checked the compile command line, I noticed that it contains the -mmacosx-version-min=10.6 flag. I tried to update my .pro file as follows, but it seems that this is not taken into account:

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

macx {
    -mmacosx-version-min=10.7
}

Any suggestions would be helpful. Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

OK found the solution after having looked at a similar question: QtCreator build system is broken after OSX upgrade

You can change the minimal Mac OS X target by updating the qmake.conf file for clang in your Qt installation (I am using Qt5.3). The file is located in the Qt installation directory at Qt/5.3/clang_64/mkspecs/macx-clang/qmake.conf The updated version is given below:

#
# qmake configuration for Clang on OS X
#

MAKEFILE_GENERATOR      = UNIX
CONFIG                 += app_bundle incremental global_init_link_order lib_version_first     plugin_no_soname
QMAKE_INCREMENTAL_STYLE = sublib

include(../common/macx.conf)
include(../common/gcc-base-mac.conf)
include(../common/clang.conf)
include(../common/clang-mac.conf)

#QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7

load(qt_config)

Note that I've commented out the default QMAKE_MACOSX_DEPLOYMENT_TARGET version providing with the Qt install.

Finally, you can also specify which sdk to use in your .pro file as follows:

macx {
    QMAKE_MAC_SDK = macosx10.9
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...