Qt5对于c++11的支持

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
  • 3
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值