Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Removing warning flags in Qt Creator
Qt 6.12 LTS is out! See what's new in the release blog

Removing warning flags in Qt Creator

Scheduled Pinned Locked Moved Installation and Deployment
4 Posts 3 Posters 6.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        [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?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          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"

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt
          • Unsolved