Qt Creator,项目工具包中的编译器被忽略 [英] Qt Creator, Compiler in kit for project is being ignored
问题描述
我正在运行macOS High Sierra(10.13.2)和Qt 5.10.0.我想在我的应用程序中使用OpenMP.
I am running macOS High Sierra (10.13.2) and Qt 5.10.0. I would like to use OpenMP with my application.
我已在我的.pro文件中添加了以下标志
I have added the following flags to my .pro file
QMAKE_CXXFLAGS += -fopenmp
QMAKE_LFLAGS += -fopenmp
LIBS += -fopenmp
macOS上的默认编译器不包含OpenMP.我通过不支持OpenMP的自制软件安装了gcc
.
The default compilers on macOS do not contain OpenMP. I installed gcc
through homebrew which does support OpenMP.
在Build&下Qt Creator的运行->编译器选项卡,我添加了自制软件g++
和gcc
编译器(/usr/local/Cellar/gcc/7.2.0/bin/{gcc-7,g++-7}
).然后,我选择了我正在使用的工具包,并将编译器更改为我在编译器"选项卡下添加的自制安装的编译器.
Under the Build & Run -> Compilers tab of Qt Creator, I added the homebrew g++
and gcc
compilers (/usr/local/Cellar/gcc/7.2.0/bin/{gcc-7,g++-7}
). I then selected the kit that I am using and changed the compiler to be the homebrew installed compiler that I added under the compilers tab.
如果在设置此套件并重建项目后检查Qt Creator生成的Makefile
,我会发现CC
和CXX
没有使用我指定的编译器.
这是它们在Makefile
中的值:
If I inspect the Makefile
generated by Qt Creator after setting this kit and rebuilding the project, I find the CC
and CXX
are not using the compiler that I have specified.
Here are their values in the Makefile
:
CC = /Library/Developer/CommandLineTools/usr/bin/clang
CXX = /Library/Developer/CommandLineTools/usr/bin/clang++
这些应该是/usr/local/Cellar/gcc/7.2.0/bin/g++-7
和/usr/local/Cellar/gcc/7.2.0/bin/gcc-7
.
我现在得到的编译器输出是:
The compiler output that I get now is:
18:14:48:开头:"/usr/bin/make"
18:14:48: Starting: "/usr/bin/make"
/usr/local/Cellar/qt/5.10.0/bin/qmake -o Makefile ../Practice/Practice.pro -spec macx-g ++ CONFIG + =调试CONFIG + = x86_64 CONFIG + = qml_debug
/usr/local/Cellar/qt/5.10.0/bin/qmake -o Makefile ../Practice/Practice.pro -spec macx-g++ CONFIG+=debug CONFIG+=x86_64 CONFIG+=qml_debug
/Library/Developer/CommandLineTools/usr/bin/g ++ -c -pipe -fopenmp -g -std = gnu ++ 11 -arch x86_64 -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk- mmacosx-version-min = 10.10 -Wall -W -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB. -I/usr/local/Cellar/qt/5.10.0/lib/QtQuick.framework/Headers -I/usr/local/Cellar/qt/5.10.0/lib/QtGui.framework/Headers -I/usr/local /Cellar/qt/5.10.0/lib/QtQml.framework/Headers -I/usr/local/Cellar/qt/5.10.0/lib/QtNetwork.framework/Headers -I/usr/local/Cellar/qt/5.10 .0/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/System/Library/Frameworks /AGL.framework/Headers -I/usr/local/Cellar/qt/5.10.0/mkspecs/macx-g ++ -F/usr/local/Cellar/qt/5.10.0/lib -o main.o ../Practice/main.cpp
/Library/Developer/CommandLineTools/usr/bin/g++ -c -pipe -fopenmp -g -std=gnu++11 -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk -mmacosx-version-min=10.10 -Wall -W -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../Practice -I. -I/usr/local/Cellar/qt/5.10.0/lib/QtQuick.framework/Headers -I/usr/local/Cellar/qt/5.10.0/lib/QtGui.framework/Headers -I/usr/local/Cellar/qt/5.10.0/lib/QtQml.framework/Headers -I/usr/local/Cellar/qt/5.10.0/lib/QtNetwork.framework/Headers -I/usr/local/Cellar/qt/5.10.0/lib/QtCore.framework/Headers -I. -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/AGL.framework/Headers -I/usr/local/Cellar/qt/5.10.0/mkspecs/macx-g++ -F/usr/local/Cellar/qt/5.10.0/lib -o main.o ../Practice/main.cpp
c声:错误:不支持的选项'-fopenmp'
clang: error: unsupported option '-fopenmp'
make:*** [main.o]错误1
make: *** [main.o] Error 1
18:14:49:进程"/usr/bin/make"以代码2退出.
18:14:49: The process "/usr/bin/make" exited with code 2.
在构建/部署项目实践时出错(工具包:台式机) 在执行步骤制作"时
Error while building/deploying project Practice (kit: Desktop) When executing step "Make"
为什么Qt Creator生成的Makefile
没有使用我在使用的套件中指定的编译器?
Why is the Makefile
generated by Qt Creator not using the compiler that I am specifying in the kit that I am using?
推荐答案
因为您使用的mkspec macx-g++
将覆盖CC和CXX设置.作为临时的解决方法,请尝试直接在pro文件中设置它们:
Because the mkspec macx-g++
you're using will override CC and CXX settings. As a temporary workaround, try setting them in the pro file directly:
QMAKE_CC = /usr/local/Cellar/gcc/7.2.0/bin/gcc-7
QMAKE_CXX = /usr/local/Cellar/gcc/7.2.0/bin/g++-7
您可能要为工具包编辑mkspec(或制作一个新的mkspec)并在其中设置这些变量.
You may want to edit the mkspec (or making a new one) for your kit and set those variables there.
要找到mkspec文件(qmake.conf):
To find the mkspec file (qmake.conf):
INSTALLDIR=`qmake -query QT_INSTALL_CONFIGURATION`
MKSPECNAME=`qmake -query QMAKE_SPEC`
cd $INSTALLDIR/mkspecs/$MKSPECNAME
关于为什么必须两次设置编译器的原因:Qt Creator旨在成为通用的c ++ IDE,因此能够管理非Qt项目,这些项目不使用qmake
但仍然需要编译器.
As to why you have to set the compilers twice: Qt Creator is meant to be a generic c++ IDE, thus able to manage non-Qt projects, which don't use qmake
but need a compiler anyway.
这篇关于Qt Creator,项目工具包中的编译器被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!