将-std = gnu ++ 11编译器标志添加到QMake [英] Adding -std=gnu++11 compiler flag to QMake
问题描述
我正在使用mingw32和g ++在windows上编译qt5.7。
当执行configure.bat时,我得到这个错误:
C:\ qt-everywhere-opensource- src-5.7.0 \configure.bat -prefix C:\ Qt-5.7 -skip qttools -skip qtwebchannel -skip qtwebengine -skip qtcharts -skip qtdatavis3d -platform win32-g ++
C:\ qt-everywhere-opensource-src-5.7.0\qtbase / qmake / library / qmakebuiltins。 cpp:在成员函数'QByteArray QMakeEvaluator :: getCommandOutput(const QString&)const':
C:\ qt-everywhere-opensource-src-5.7.0\qtbase / qmake / library / qmakebuiltins.cpp: 419:94:error:'_popen'未在此范围内声明
+ QLatin1String(&)+ args).toLocal8Bit()。constData(),r)){
导致此错误的命令为:
g ++ -c -o qmakebuiltins.o -std = c ++ 11 -DUNICODE -ffunction-sections -g -IC:\ qt-everywhere-opensour ce-src-5.7.0 \ qtbase / qmake +很多东西
另外,下面的代码:
#include
main(int argc,char ** argv)
{
FILE * f = popen(argv [1],r);
返回0;
不能用
$ b $进行编译b
g ++ -std = c ++ 11 mytest.cpp -o mytest
:
> g ++ -std = gnu ++ 11 mytest.cpp -o mytest
>。
$ c $所以问题是我该如何修改选项c ++ 11到gnu ++ 11,它被配置文件传递给g ++?
谢谢
解决方案I am compiling qt5.7 on windows with mingw32 and g++.4.9.3. While executing the configure.bat, I get this error :
C:\qt-everywhere-opensource-src-5.7.0\configure.bat -prefix C:\Qt-5.7 -skip qttools -skip qtwebchannel -skip qtwebengine -skip qtcharts -skip qtdatavis3d -platform win32-g++
C:\qt-everywhere-opensource-src-5.7.0\qtbase/qmake/library/qmakebuiltins.cpp: In member function 'QByteArray QMakeEvaluator::getCommandOutput(const QString&) const': C:\qt-everywhere-opensource-src-5.7.0\qtbase/qmake/library/qmakebuiltins.cpp:419:94: error: '_popen' was not declared in this scope + QLatin1String(" && ") + args).toLocal8Bit().constData(), "r")) {
The command that leads to this error is :
g++ -c -o qmakebuiltins.o -std=c++11 -DUNICODE -ffunction-sections -g -IC:\qt-everywhere-opensource-src-5.7.0\qtbase/qmake + lot of stuff
Also, the following code :
#include <stdio.h> int main( int argc, char ** argv ) { FILE * f = popen( argv[ 1 ], "r" ); return 0; }
doesn't compile with
g++ -std=c++11 mytest.cpp -o mytest
but with :
>g++ -std=gnu++11 mytest.cpp -o mytest
So the question is how can I modify the option c++11 to gnu++11 which is passed to g++ by the configure file ? Thank you
解决方案According to Qt's Wiki, with the current version of qmake you are using, you can also use
CONFIG += c++11
.这篇关于将-std = gnu ++ 11编译器标志添加到QMake的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!