The qt source comes with some examples. After downloading it from the internet, I go to the examples/painting/concentriccircles and run 'qmake' and it generates the Makefile (which sets CC=gcc) from the .pro file and after make, I can run the demo program concentriccircles on my CentOS machine. (running x86 code).
Now I have a project running Qt on a sparc machine running an OS and I already have the build tree set up. If I move the whole concentriccircles directory to somewhere in the build tree, when I run 'qmake', the generated Makefile sets the CC=sparc-xxx-gcc instead of just plain gcc(which is for x86 host). In fact, without moving the directory, if I run qmake from the sparc build tree, it makes the Makefile for sparc. (regardless of the .pro file)
How does qmake know that I'm building the qt program for sparc machine just from the location where I run qmake? Below is the concentriccircles.pro file.
HEADERS = circlewidget.h \
window.h
SOURCES = circlewidget.cpp \
main.cpp \
window.cpp
# install
target.path = $$[QT_INSTALL_EXAMPLES]/painting/concentriccircles
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS concentriccircles.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/painting/concentriccircles
INSTALLS += target sources
symbian {
TARGET.UID3 = 0xA000A64A
include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
}
maemo5: include($$QT_SOURCE_TREE/examples/maemo5pkgrules.pri)
qmake was created by Trolltech (now The Qt Company). It is distributed and integrated with the Qt application framework, and automates the creation of moc (meta object compiler) and rcc (resource compiler) sources, which are used in Qt's meta-object system and in the integration of binary resources (e.g., pictures).
The qmake tool helps simplify the build process for development projects across different platforms. It automates the generation of Makefiles so that only a few lines of information are needed to create each Makefile. You can use qmake for any software project, whether it is written with Qt or not.
For simple projects, you only need to run qmake in the top level directory of your project. By default, qmake generates a Makefile that you then use to build the project, and you can then run your platform's make tool to build the project. qmake can also be used to generate project files.
g++ is used by qmake and gcc is configured by the kit.
First of all you need to know which spec qmake is using by default. You can check this by doing
qmake -query QMAKE_MKSPECS
The result should be path containing all mkspecs i.e.
/usr/share/qt4/mkspecs
Now you can check default mkspec:
ls -lah /usr/share/qt4/mkspecs/default
Result (for my configuration)
/usr/share/qt4/mkspecs/default -> linux-g++-64
So clearly you can see that I have by default linux-g++-64 mkspec
Now let's see what's inside the spec:
cat /usr/share/qt4/mkspecs/default/qmake.conf
Result:
#
# qmake configuration for linux-g++
#
# Written for GNU/Linux platforms that have both lib and lib64 directories,
# like the AMD Opteron.
#
MAKEFILE_GENERATOR = UNIX
TARGET_PLATFORM = unix
TEMPLATE = app
CONFIG += qt warn_on release incremental link_prl gdb_dwarf_index
QT += core gui
QMAKE_INCREMENTAL_STYLE = sublib
QMAKE_CFLAGS = -m64
QMAKE_LFLAGS = -m64
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
QMAKE_LIBDIR_X11 = /usr/X11R6/lib64
QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib64
load(qt_config)
As you can see it includes some other .conf files. In my configuration g++-unix.conf includes simply g++-base.conf so I'll get straight to it:
cat /usr/share/qt4/mkspecs/common/g++-base.conf
Result:
#
# Qmake configuration for the GNU C++ compiler
#
# Before making changes to this file, please read the comment in
# gcc-base.conf, to make sure the change goes in the right place.
#
# To verify that your change has the desired effect on the final configuration
# you can use the manual test in tests/manual/mkspecs.
#
QMAKE_CC = gcc
QMAKE_LINK_C = $$QMAKE_CC
QMAKE_LINK_C_SHLIB = $$QMAKE_CC
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -g
QMAKE_CXX = g++
QMAKE_LINK = $$QMAKE_CXX
QMAKE_LINK_SHLIB = $$QMAKE_CXX
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
QMAKE_PCH_OUTPUT_EXT = .gch
QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CFLAGS_USE_PRECOMPILE = -include ${QMAKE_PCH_OUTPUT_BASE}
QMAKE_CXXFLAGS_PRECOMPILE = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
As you can see compiler is strictly defined by choosen qmake spec file. You can use different spec file by calling
qmake -spec SPEC_NAME
SPEC_NAME should be directory name inside qmake -query QMAKE_MKSPECS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With