I am trying to compile c++11 code on the Mac OS X using Qt Creator/qmake and I am getting the following error:
我正在尝试使用Qt Creator/qmake在Mac OS X上编译c++11代码,我得到了以下错误:
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:
当我检查编译命令行时,我注意到它包含-mmacosx-version-min=10.6标志。我试着更新我的.pro文件,但似乎没有考虑到这一点:
QMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++
macx {
-mmacosx-version-min=10.7
}
Any suggestions would be helpful. Thanks!
任何建议都是有益的。谢谢!
2 个解决方案
#1
7
You can actually add that deployment target line QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
to your QMake project file. You don't have to reinstall Qt.
实际上,您可以将部署目标行QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6添加到QMake项目文件中。你不需要重新安装Qt。
One thing to keep in mind, though: if you build any other libraries that you include in your application bundle, make sure they're also compiled for backwards compatibility! In case it helps with any libraries, there's an equivalent CMake command as well, CMAKE_OSX_DEPLOYMENT TARGET
.
但是要记住一点:如果您构建了应用程序包中包含的任何其他库,请确保它们也被编译为向后兼容!如果它帮助了任何库,也有一个等效的CMake命令,CMAKE_OSX_DEPLOYMENT目标。
#2
6
OK found the solution after having looked at a similar question: QtCreator build system is broken after OSX upgrade
在查看了类似的问题之后,OK找到了解决方案:在OSX升级后,QtCreator构建系统被打破。
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来更改最小的Mac OS X目标。在Qt安装中,clang的conf文件(我正在使用Qt5.3)。该文件位于Qt/5.3/clang_64/mkspec /macx-clang/qmake的Qt安装目录中。conf的更新版本如下:
#
# 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.
注意,我已经注释掉了提供Qt安装的默认QMAKE_MACOSX_DEPLOYMENT_TARGET版本。
Finally, you can also specify which sdk to use in your .pro file as follows:
最后,您还可以指定在.pro文件中使用哪个sdk:
macx {
QMAKE_MAC_SDK = macosx10.9
}
#1
7
You can actually add that deployment target line QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
to your QMake project file. You don't have to reinstall Qt.
实际上,您可以将部署目标行QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6添加到QMake项目文件中。你不需要重新安装Qt。
One thing to keep in mind, though: if you build any other libraries that you include in your application bundle, make sure they're also compiled for backwards compatibility! In case it helps with any libraries, there's an equivalent CMake command as well, CMAKE_OSX_DEPLOYMENT TARGET
.
但是要记住一点:如果您构建了应用程序包中包含的任何其他库,请确保它们也被编译为向后兼容!如果它帮助了任何库,也有一个等效的CMake命令,CMAKE_OSX_DEPLOYMENT目标。
#2
6
OK found the solution after having looked at a similar question: QtCreator build system is broken after OSX upgrade
在查看了类似的问题之后,OK找到了解决方案:在OSX升级后,QtCreator构建系统被打破。
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来更改最小的Mac OS X目标。在Qt安装中,clang的conf文件(我正在使用Qt5.3)。该文件位于Qt/5.3/clang_64/mkspec /macx-clang/qmake的Qt安装目录中。conf的更新版本如下:
#
# 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.
注意,我已经注释掉了提供Qt安装的默认QMAKE_MACOSX_DEPLOYMENT_TARGET版本。
Finally, you can also specify which sdk to use in your .pro file as follows:
最后,您还可以指定在.pro文件中使用哪个sdk:
macx {
QMAKE_MAC_SDK = macosx10.9
}