Removing warning flags in Qt Creator



  • Hi. I use Qt Creator as a general C++11 IDE after following the instructions given "here":http://dkrypted.wordpress.com/2012/05/14/best-ide-for-c-qt-creator/.

    Since my codes are often simple and barely exceed 100 lines(I also don't use any libraries), I would like my compilation to be faster. This is mainly because I make teeny tiny changes often(like add a character here, there, etc) and it is irritating to wait 10 seconds after each minor change for the code to compile.
    Now, I believe the reason is the large number of flags. In terminal, I would normally use
    g++ -std=c++0x main.cpp

    So, I spent at least a week on google trying to figure out how to modify the project file in order to disable as many compiler flags as I can. I found a few useful topics such as "this":http://stackoverflow.com/questions/18667291/disable-wall-compiler-warnings-in-a-qt-project but I still haven't succeeded in removing many warning flags that I do not need. It would be really nice if someone can tell me how to remove as many compiler flags as possible. It would be sufficient for only the "barebone" flags to remain.

    The current compile output is
    g++ -c -m64 -pipe -std=c++0x -O2 -Wall -W -fPIE -I/usr/share/qt5/mkspecs/linux-g++-64 -I. -o main.o main.cpp
    g++ -m64 -Wl,-O1 -o serv main.o

    Of course, I am doing this because I think this makes the compilation faster. If there is a better way, please do tell me. I should also mention that I am not really much of a programmer(as you would have guessed), I am just a student. So, please make your instructions easily understandable.

    Thanks.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    If I understood you correctly, you are not using Qt for these little projects so you can start a non-Qt project, that should give you a "clean" setup for your application with no special flags set.

    Hope it helps



  • [quote author="SGaist" date="1392499147"]Hi and welcome to devnet,

    If I understood you correctly, you are not using Qt for these little projects so you can start a non-Qt project, that should give you a "clean" setup for your application with no special flags set.

    Hope it helps[/quote]

    Thanks for replying. I navigate as follows:
    New project -> Non Qt Project -> Plain C++ Project -> Desktop Release Kit(default)
    The same compilation takes place.
    Actually, if you see my compile output, you don't see the Qt flags, but I want to remove the other flags like -Wall or -W or -O2 too because they are not necessary for me.
    So, how do I do this?



  • You can disable -Wall by
    CONFIG += warn_off

    Another way to get rid off all unecessary flags is to use make instead of qmake.

    create a directory for you project
    put a simple Makefile there, something like this

    @
    all: hello

    hello: main.cpp
    g++ -std=c++11 -o $@ $<

    clean:
    rm -f hello
    @

    Create an empty main.cpp

    Then from QtCreator
    New Project/Import/Import Existing and select your new directory.
    Edit main.cpp and build it.

    If you plan to run an executable from QtCreator then you will need to modify a project settings (Projects button on the left toolbar)
    You will need to specify an executable file in "Run Settings"


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.