Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Understand Qt's g++ calls in QtCreator
Forum Updated to NodeBB v4.3 + New Features

Understand Qt's g++ calls in QtCreator

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 2.8k 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.
  • G Offline
    G Offline
    Gradient
    wrote on last edited by
    #1

    In order to understand how Qt's file should be link with my application, I created the default Hello Word program in QtCreator and started to analyse g++'s calls. I understand everything except the following bold options :

    g++ -c -m64 -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../Qt5.0.1/5.0.1/gcc_64/mkspecs/linux-g++-64 -I../test4 -I../../Qt5.0.1/5.0.1/gcc_64/include -I../../Qt5.0.1/5.0.1/gcc_64/include/QtWidgets -I../../Qt5.0.1/5.0.1/gcc_64/include/QtGui -I../../Qt5.0.1/5.0.1/gcc_64/include/QtCore -I. -I. -I. -o moc_mainwindow.o moc_mainwindow.cpp

    Looking at gcc's man page, I can see it is for macros, but I still don't quite understand. Can someone explain this?

    Additionnaly, there is this :

    g++ -m64 -Wl,-rpath,/home/jp/Qt5.0.1/5.0.1/gcc_64 -Wl,-rpath,/home/jp/Qt5.0.1/5.0.1/gcc_64/lib -o test4 main.o mainwindow.o moc_mainwindow.o -L/usr/X11R6/lib64 -L/home/jp/Qt5.0.1/5.0.1/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread

    Again, I understand it is related to the linker, but I don't understand those two options. I looked in gcc's man page and didn't the -r option. Where can I read about linker's options?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      -DWHATEVER_SYMBOL is essentially the same as creating a header file that is included in each and every file and contains #define WHATEVER_SYMBOL 1

      -m64 tells the compiler to generate code for the x86-64 architecture

      -Wl passes following, comma separated, options to the linker

      -rpath (linker option) adds a dir to the runtime library search path

      You can find a list of all the params for the gcc compiler "here":http://gcc.gnu.org/onlinedocs/gcc/Invoking-GCC.html#Invoking-GCC
      As for the linker options, check the man pages of "ld" or take a look "here":http://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tobias.hunger
        wrote on last edited by
        #3

        One nitpick: Creator does not call g++, it calls make which then in turn does everything necessary to generate the binaries (incl. calling make).

        1 Reply Last reply
        0
        • G Offline
          G Offline
          Gradient
          wrote on last edited by
          #4

          ""-DWHATEVER_SYMBOL is essentially the same as creating a header file that is included in each and every file and contains #define WHATEVER_SYMBOL 1""

          And what is the point of defining these symbols? Are they used after?

          Is it for example, if I had written in my code "#ifdef WHATEVER_SYMBOL .... #endif" ?

          1 Reply Last reply
          0
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Well, they're obviously not just for fun there :)

            Yes, it's for "turning on/off" parts of code with ifdefs.
            For example you could to something like:
            @
            #ifdef _DEBUG
            #define printSome(x) printSomeDebuggingMessage(x);
            #else
            #define printSome(x)
            #endif
            @
            or
            @
            #ifdef SOME_FLAG
            static SomeType turnSomeFeatureOn( true );
            #else
            static SomeType turnSomeFeatureOn( false );
            #endif
            @

            Qt's names are pretty descriptive, like QT_QML_DEBUG turns on debugging of the QML module etc.. But if you're really curious you can just take Qt source and look those up.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              Gradient
              wrote on last edited by
              #6

              Thank you! It is clear now!

              "" Well, they’re obviously not just for fun there :) ""

              It could have been. There is also "-I. -I. -I." in the g++ call which is obviously there just for fun. :)

              1 Reply Last reply
              0
              • Chris KawaC Offline
                Chris KawaC Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on last edited by
                #7

                More fun might be finding out where those -I.s actually come from :)
                The first one is for the configuration directory, eg. on windows with msvc compiler the first -I. becomes -I"release" or -I"debug". I guess without shadow building this would become -I. but I haven't checked.

                Don't know where the other two come from, but I'm not really that interested :)

                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 Extensions
                • Unsolved