Where in Qt Creator do I pass arguments to a compiler?

梦想的初衷 提交于 2019-12-28 04:00:32

问题


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


回答1:


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")



回答2:


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.




回答3:


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



回答4:


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

QMAKE_CFLAGS += -std=c99



回答5:


in the .pro file you can add variables which modify the make behavior for example, if you try to execute the following command:

g++ -Wall -I/usr/include/cppconn -o exe main.cpp -L/usr/lib -lmysqlcppconn

you must add the following lines in the .pro file

INCLUDEPATH += /usr/include/cppconn
LIBS += -L/usr/lib -lmysqlcppconn

View Screenshot

For more information on the available variables that QT IDE uses, you can visit the following link where they explain in more detail each one. Qt Documentation: Variables




回答6:


In your Qmake project file probably



来源:https://stackoverflow.com/questions/7980499/where-in-qt-creator-do-i-pass-arguments-to-a-compiler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!