Where in Qt Creator do I pass arguments to a compi

2019-01-11 16:16发布

Where in Qt Creator do I pass arguments to a compiler?
It isn't really that obvious.

5条回答
淡お忘
2楼-- · 2019-01-11 16:55

In your Qmake project file probably

查看更多
看我几分像从前
3楼-- · 2019-01-11 17:03

Depending on your build system it's either in your qmake project file(.pro, standard for new projects) or in one of the CMake files (CMakeLists.txt, used by KDE and several other projects).

Using .pro:

QMAKE_CXXFLAGS += -O2

Using CMake:

set( CMAKE_CXX_FLAGS "-g -Wall")
查看更多
ら.Afraid
4楼-- · 2019-01-11 17:05

If your intention is to precompile some source code you can do like this:

/A/ In your .pro file you can add a line like this:

DEFINES += HOPLA

/B/ In you .cpp or .h file you can use it like this

#ifdef HOPLA
// Do something
#else
// Do something different
#endif
查看更多
迷人小祖宗
5楼-- · 2019-01-11 17:05

for C projects, add the following line in .pro file

QMAKE_CFLAGS += -std=c99
查看更多
干净又极端
6楼-- · 2019-01-11 17:11

To add compiler flags, open your .pro file and add a line like this:

QMAKE_CXXFLAGS += -std=c++0x

For standard flags like debug vs. release etc. you should try to use the predefined qmake options (see QMake documentation) for the sake of platform and compiler-independency, as QMake will map them to the compiler-specific flags.

查看更多
登录 后发表回答