您的位置:首页 > 编程语言 > C语言/C++

Qt5对于c++11的支持

2016-07-04 18:20 363 查看

Qt5对于c++11的支持

自从qt5发布,就公布了Qt5对c++11的支持,qt上最明显的是可以使用lumda表达式了,在connect信号的时候写一些比较简单的槽函数还是很方便的。

但是最近在移植qt5到arm的时候发现,Qt5.7的版本连编译的时候都要gcc编译器支持c++11才能通过configure

checking for C++11...
arm-none-linux-gnueabi-g++ -c -pipe -O2 -g -std=gnu++11 -Wall -W -fPIC  -I. -I../../../mkspecs/linux-arm-gnueabi-g++ -o c++11.o c++11.cpp
cc1plus: error: unrecognized command line option "-std=gnu++11"
Makefile:180: recipe for target 'c++11.o' failed
make: *** [c++11.o] Error 1
C++11 disabled.
ERROR: Qt requires a C++11 compiler and yours does not seem to be that.
Please upgrade.


很不幸,笔者用的是飞思卡尔的imx283,属于armv5,官方给的交叉编译工具并不支持c++11。百度搜了下,发现arm9几乎都不支持c++11,所以Qt5.7的移植宣布失败。

笔者在以一种万念俱灰的心情抓了半个小时头发之后,不甘心地解压了Qt5.4版本的压缩包(出于对qtquick 2.0 的执着,笔者认为qml能够解决目前所有的问题,嘿嘿这是不是一种信仰)。在配置参数上加上了-no-c++11,配置通过,make通过。

你可能会觉得如果在5.7的版本也加上-no-c++11也能避免对支持c++11的检测的。答案是no,5.7的configure选线没有-no-c++11,只有:

-c++std <edition> .. Compile Qt with C++ standard edition (c++11, c++14, c++1z)
Default: highest supported


出于对尽量靠近最新版本的考虑,笔者又下Qt5.6的版本,同样加入了-no-c++11的配置项,结果:

NOTICE: The -no-c++11 / --c++-level=c++98 option is deprecated.

Qt 5.7 will require C++11 support. The options are in effect for this
Qt 5.6 build, but you should update your build scripts to remove the
option and, if necessary, upgrade your compiler.


结果很明显的出来了,Qt5.6.1还能用c++98编,Qt5.7就只能用c++11或者更高版本了。

-c++std <edition> .. Compile Qt with C++ standard edition (c++98, c++11, c++14, c++1z)
Default: highest supported
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  qt qt5 gcc arm