简体   繁体   English

在QT 5.7 Ubuntu上使用GCC 6.3进行编译

[英]Compile using GCC 6.3 on QT 5.7 Ubuntu

I want to use c++14 features so I wanted to use the GCC 6.3 compiler. 我想使用c ++ 14功能,所以我想使用GCC 6.3编译器。 I've done the list of commands found here 我已经完成了此处找到的命令列表

Afterwards, I created a new kit, and used the newly installed xg++ compiler here's the compiler description and added the following in my .pro CONFIG += c++11 c++14 之后,我创建了一个新工具包,并使用了新安装的xg ++编译器, 这里是编译器的说明,并在.pro CONFIG += c++11 c++14添加了以下内容

Still the compiler doesn't recognize strings/cout/endl and can't use auto for automatic return type deduction. 编译器仍然无法识别字符串/ cout / endl,并且不能将auto用于自动返回类型推导。 Also, the binary literals are not recognized. 同样,二进制文字不被识别。

what I am missing here? 我在这里想念什么?

It turns out that it's a bug in Qt Creator not switching to use the given compiler by providing its path in the kit. 事实证明,这是Qt Creator中的一个错误,它没有通过在工具包中提供其路径来切换为使用给定的编译器。 However, I executed the following steps from terminal: 但是,我从终端执行了以下步骤:

// Update & Build Essentials & add ppa of the gcc & update again
$ sudo apt-get update
$ sudo apt-get install build-essential software-properties-common -y 
$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y  // ppa of gcc 6.3
$ sudo apt-get update
$ sudo apt-get install gcc-snapshot -y
$ sudo apt-get update 

// Install the gcc and Add the gcc as an alternative
$ sudo apt-get install gcc-6 g++-6 -y
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6

// You can switch the gcc verions via
$ sudo update-alternatives --config gcc

and made an alternative to my existing GCC. 并替代了我现有的GCC。 Once I restored the default kit of Qt creator and set the default GCC to 6.3 instead of 4.8, I was able to run C++14 features with ease provided that CONFIG += c++14 is in the .pro. 一旦恢复了Qt Creator的默认工具包并将默认GCC设置为6.3而不是4.8,只要CONFIG += c++14位于.pro中,我便可以轻松运行C ++ 14功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM