Configuring the GCC compiler switches in Qt, QtCreator, and QMake(在 Qt、QtCreator 和 QMake 中配置 GCC 编译器开关)
问题描述
我最近尝试使用 Qt Creator 1.3.2、Qt 4.6.2 和 GCC4.4.0(32 位版本)在 Windows 7(64 位)上编译使用一些实验性 C++0x 扩展的应用程序并遇到以下(致命)错误:
I recently tried to use Qt Creator 1.3.2, Qt 4.6.2, and GCC 4.4.0 (32-bit version) on Windows 7 (64-bit) to compile an application using some of the experimental C++0x extensions and encountered the following (fatal) error:
这个文件需要编译器和库支持来支持即将到来的ISO C++ 标准,C++0x.此支持目前处于试验阶段,必须使用 -std=c++0x 或 -std=gnu++0x 编译器选项启用.
This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.
在寻找解决方案的过程中,我遇到了qmake 和编译器标志?,并将以下内容添加到 .pro 文件中:
In my search for a solution, I came across the thread qmake and compiler flags?, and added the following to the .pro file:
CXXFLAGS += -std=c++0x
但这似乎没什么区别.
所以,我希望有一些标签需要添加到 .pro(项目)文件中,但我以前从未在 Qt、QMake 和 QtCreator 中使用过 GCC 编译器开关,而且我不确定正确的祈求/咒语.所以,我的问题是在使用 QtCreator、QMake 和 Qt 时如何设置 GCC 编译器开关?
So, I expect there's some tag I need to add to the .pro (project) file, but I've never messed with the GCC compiler switches in Qt, QMake, and QtCreator before, and I am uncertain about the proper invokation / incantation. So, my question is how do you set GCC compiler switches when using QtCreator, QMake, and Qt?
推荐答案
归结为阅读手册.而不是在 .pro 文件中使用 CXXFLAGS,您需要使用 QMAKE_CXXFLAGS 如下:
It boils down to reading the manual. Instead of using CXXFLAGS in the .pro file, you need to use QMAKE_CXXFLAGS as in:
main.cpp:
#include <cinttypes>
int main() { return 0; }
main.pro:
SOURCES += main.cpp
QMAKE_CXXFLAGS += -std=c++0x
这篇关于在 Qt、QtCreator 和 QMake 中配置 GCC 编译器开关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Qt、QtCreator 和 QMake 中配置 GCC 编译器开关
基础教程推荐
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
