当前位置: 代码迷 >> QT开发 >> 使用qmake自动编译Qt程序,如何设置g++的编译选项
  详细解决方案

使用qmake自动编译Qt程序,如何设置g++的编译选项

热度:88   发布时间:2016-04-25 03:55:55.0
求助:使用qmake自动编译Qt程序,怎么设置g++的编译选项?
用qmake自动生成makefile,再用make编译Qt程序时,g++的编译选项大概是这么多...:
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN ...

我希望在我的Qt程序中使用一些C++0x的特性,这需要在g++的编译选项中加入这两个:
-std=c++0x -USTRICT_ANSI


即,变成:
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -std=c++0x -USTRICT_ANSI

高手们...请问应该怎样做呢?

------解决方案--------------------
.pro 文件 QMAKE_CXXFLAGS


This variable contains the C++ compiler flags that are used when building a project. The value of this variable is typically handled by qmake or qmake.conf and rarely needs to be modified. The flags specific to debug and release modes can be adjusted by modifying the QMAKE_CXXFLAGS_DEBUG and QMAKE_CXXFLAGS_RELEASE variables, respectively.

------解决方案--------------------
.pro中添一句:
QMAKE_CXXFLAGS += -std=c++0x -USTRICT_ANSI