What does Qt do after you ./configure when compiling Qt?
Qt source code, and configure output(with -v when ./configure).
configure file is in fact a shell. Just like this:
#!/bin/sh
#-------------------------------------------------------------------------------
# script initialization
#-------------------------------------------------------------------------------
# the name of this script
relconf=`basename $0`
# the directory of this script is the "source tree"
relpath=`dirname $0`
relpath=`(cd "$relpath"; /bin/pwd)`
# the current directory is the "build tree" or "object tree"
outpath=`/bin/pwd`
...
This file tells us everything about configuring Qt.
Build qmake. Qt uses qmake to manage dependency, build and deployment. So building qmake is the very first thing to do. It calls g++ to compile source code in qtbase/qmake/, change .h&&.cpp into .o and put all .o file into executable file qmake in qtbase/bin.
g++ -o "../bin/qmake" project.o option.o property.o main.o ioutils.o proitems.o qmakevfs.o qmakeglobals.o qmakeparser.o qmakeevaluator.o qmakebuiltins.o makefile.o unixmake2.o unixmake.o mingw_make.o winmakefile.o projectgenerator.o meta.o makefiledeps.o metamakefile.o xmloutput.o pbuilder_pbx.o msvc_vcproj.o msvc_vcxproj.o msvc_nmake.o msvc_objectmodel.o msbuild_objectmodel.o cesdkhandler.o qtextcodec.o qutfcodec.o qstring.o qstring_compat.o qstringbuilder.o qtextstream.o qiodevice.o qdebug.o qmalloc.o qglobal.o qarraydata.o qbytearray.o qbytearraymatcher.o qdatastream.o qbuffer.o qlist.o qfiledevice.o qfile.o qfilesystementry.o qfilesystemengine.o qfsfileengine.o qfsfileengine_iterator.o qregexp.o qvector.o qbitarray.o qdir.o qdiriterator.o quuid.o qhash.o qfileinfo.o qdatetime.o qstringlist.o qabstractfileengine.o qtemporaryfile.o qmap.o qmetatype.o qsettings.o qsystemerror.o qlibraryinfo.o qvariant.o qvsnprintf.o qlocale.o qlocale_tools.o qlinkedlist.o qnumeric.o qcryptographichash.o qxmlstream.o qxmlutils.o qlogging.o qjson.o qjsondocument.o qjsonparser.o qjsonarray.o qjsonobject.o qjsonvalue.o qfilesystemengine_unix.o qfilesystemiterator_unix.o qfsfileengine_unix.o qlocale_unix.o -Wl,--gc-sections
This is one of the compile outputs, after which qmake exists in qtbase/bin.
qmake is more than a simple tool to generate Makefile. It contains essential env for Qt, including include_path, lib_path(of course Qt libs). That means, if you need to write a simple program using Qt libs, you don’t need to specify Qt lib_path if using qmake, just QT += widgets for example.
So, if you change the absolute path of qmake after building, qmake will no more work.
Running configuration tests. Test code is in qtbase/config.tests. It does a lot of tests one by one, like this:
Determining architecture... ()
g++ -c -pipe -g -Wall -W -fPIC -I. -I../../mkspecs/linux-g++ -o arch.o arch.cpp
g++ -o arch arch.o
Found architecture in binary
CFG_ARCH="x86_"
CFG_CPUFEATURES=" mmx sse sse2"
System architecture: 'x86_'
Host architecture: 'x86_'
C++11 auto-detection... ()
g++ -c -pipe -O2 -std=c++0x -Wall -W -fPIC -I. -I../../../mkspecs/linux-g++ -o c++11.o c++11.cpp
g++ -Wl,-O1 -o c++11 c++11.o
C++11 enabled.
sse2 auto-detection... ()
g++ -c -pipe -msse2 -g -Wall -W -fPIC -I. -I../../../mkspecs/linux-g++ -o sse2.o sse2.cpp
g++ -o sse2 sse2.o
sse2 enabled.
...
DB2 auto-detection... ()
g++ -c -pipe -O2 -Wall -W -fPIC -I. -I../../../mkspecs/linux-g++ -o db2.o db2.cpp
db2.cpp:34:20: fatal error: sqlcli.h: No such file or directory
compilation terminated.
Makefile:191: recipe for target 'db2.o' failed
make: *** [db2.o] Error 1
DB2 disabled.
...
These tests are just like Qt source code’s guard. The guard detects the system and find if there exists some libs. If the essential libs are of absence, it will throw error and stop building.
So, how does it detect the system? Give an example of EGL,
“egl.cpp”
#include <EGL/egl.h>
int main(int, char **)
{
EGLint x = 0;
EGLDisplay dpy = 0;
EGLContext ctx = 0;
eglDestroyContext(dpy, ctx);
return 0;
}
“egl.pro”
SOURCES = egl.cpp
for(p, QMAKE_LIBDIR_EGL) {
exists($$p):LIBS += -L$$p
}
!isEmpty(QMAKE_INCDIR_EGL): INCLUDEPATH += $$QMAKE_INCDIR_EGL
!isEmpty(QMAKE_LIBS_EGL): LIBS += $$QMAKE_LIBS_EGL
CONFIG -= qt
In fact, test code contains no logic code. It only include egl.h file to see whether it will throw errors.
From this special example, we know that if you want to use EGL, QMAKE_INCDIR_EGL and QMAKE_LIBS_EGL are very important, which must be specified in some file.
It then will print the configure result list and generate Makefile.
config.tests can determine yes or no for some env. Besides, in ./configure -opengl desktop …, those parameters after ./configure does the same. More over, you can directly edit configure file to change some env’s default value.
Then start to make.
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- ovod.cn 版权所有 湘ICP备2023023988号-4
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务