How to specify target mac os x version using qmake

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

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

When I checked the compilation command line, I noticed that it contains the -mmacosx-version-min = 10.6 flag. I tried updating my .pro file as follows, but this seems to be ignored:

 QMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++ macx { -mmacosx-version-min=10.7 } 

Any suggestions would be helpful. Thanks!

+8
c ++ qt macos qmake
source share
2 answers

In fact, you can add the QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 deployment target line to the QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 project file. You do not need to reinstall Qt.

Keep in mind that if you create any other libraries that you included in your application package, make sure they are also compiled for backward compatibility! In case this helps with any libraries, there is an equivalent CMake command, CMAKE_OSX_DEPLOYMENT TARGET .

+7
source share

OK found a solution by looking at a similar question: QtCreator build system damaged after OSX update

You can change the minimum target of Mac OS X by updating the qmake.conf file for clang in your Qt installation (I use Qt5.3). The file is located in the Qt installation directory in Qt / 5.3 / clang_64 / mkspecs / macx-clang / qmake.conf An 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 commented on the default version of QMAKE_MACOSX_DEPLOYMENT_TARGET, which provides a Qt installation.

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

 macx { QMAKE_MAC_SDK = macosx10.9 } 
+5
source share

All Articles