Chinaunix首页 | 论坛 | 博客
  • 博客访问: 136009
  • 博文数量: 16
  • 博客积分: 225
  • 博客等级: 民兵
  • 技术积分: 185
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-28 22:07
个人简介

人是懒惰的,只要有借口就会不想往前。如果既有明确的目标,同时道路又直直指向目标,一览无余,只等你开始往前走,那么便没有借口,一往无前。

文章分类
文章存档

2014年(2)

2013年(9)

2012年(5)

分类: LINUX

2013-11-26 16:35:15


Step 1: Downloading the Qt Sources

获取Qt源码包, 这里提供了Qt支持的所有不同开发平台的下载链接 。我这里下载

tar.gz源码包为:,如下

Step 2: Unpacking the Archive

 我下载的源码包放在/opt/tools:

root@ubuntu:/opt# cd tools/ 
root@ubuntu:/opt/tools# gunzip qt-everywhere-opensource-src-5.1.1.tar.gz                # uncompress the archive 
root@ubuntu:/opt/tools# tar xvf qt-everywhere-opensource-src-5.1.1.tar                  # unpack it

Step 3: Building the Library

运行 ./configure -help 可以获得所有配置选项及其用法的帮助。

root@ubuntu:/opt/tools# cd /opt/tools/qt-everywhere-opensource-src-5.1.1/ 
root@ubuntu:/opt/tools/qt-everywhere-opensource-src-5.1.1# ./configure -help
+ cd qtbase + /opt/tools/qt-everywhere-opensource-src-5.1.1/qtbase/configure -help Usage: configure [options] Installation options: These are optional, but you may specify install directories. -prefix ...... This will install everything relative to (default /usr/local/Qt-5.1.1) -hostprefix [dir] .. Tools and libraries needed when developing applications are installed in [dir]. If [dir] is not given, the current build directory will be used. (default PREFIX) You may use these to separate different parts of the install: -bindir ......... User executables will be installed to (default PREFIX/bin) -headerdir ...... Headers will be installed to (default PREFIX/include) -libdir ......... Libraries will be installed to (default PREFIX/lib) -archdatadir .... Arch-dependent data used by Qt will be installed to (default PREFIX) -plugindir ...... Plugins will be installed to (default ARCHDATADIR/plugins) -libexecdir ..... Program executables will be installed to (default ARCHDATADIR/libexec) -importdir ...... Imports for QML1 will be installed to (default ARCHDATADIR/imports) -qmldir ......... Imports for QML2 will be installed to (default ARCHDATADIR/qml) -datadir ........ Arch-independent data used by Qt will be installed to (default PREFIX) -docdir ......... Documentation will be installed to (default DATADIR/doc) -translationdir . Translations of Qt programs will be installed to (default DATADIR/translations) -sysconfdir ..... Settings used by Qt programs will be looked for in (default PREFIX/etc/xdg) -examplesdir .... Examples will be installed to (default PREFIX/examples) -testsdir ....... Tests will be installed to (default PREFIX/tests) -hostbindir .. Host executables will be installed to (default HOSTPREFIX/bin) -hostlibdir .. Host libraries will be installed to (default HOSTPREFIX/lib) -hostdatadir . Data used by qmake will be installed to (default HOSTPREFIX) Configure options: The defaults (*) are usually acceptable. A plus (+) denotes a default value that needs to be evaluated. If the evaluation succeeds, the feature is included. Here is a short explanation of each option: * -release ........... Compile and link Qt with debugging turned off. -debug ............. Compile and link Qt with debugging turned on. -debug-and-release . Compile and link two versions of Qt, with and without debugging turned on (Mac only). -force-debug-info .. Create symbol files for release builds. -developer-build ... Compile and link Qt with Qt developer options (including auto-tests exporting) -opensource ........ Compile and link the Open-Source Edition of Qt. -commercial ........ Compile and link the Commercial Edition of Qt. -confirm-license ... Automatically acknowledge the license (use with either -opensource or -commercial) -no-c++11 .......... Do not compile Qt with C++11 support enabled. + -c++11 ............. Compile Qt with C++11 support enabled. * -shared ............ Create and use shared Qt libraries. -static ............ Create and use static Qt libraries. * -process ........... Generate only a top-level Makefile. -fully-process ..... Generate Makefiles for the entire Qt tree. -dont-process ...... Do not generate any Makefiles. -no-largefile ...... Disables large file support. + -largefile ......... Enables Qt to access files larger than 4 GB. -no-accessibility .. Do not compile Accessibility support. Disabling accessibility is not recommended, as it will break QStyle and may break other internal parts of Qt. With this switch you create a source incompatible version of Qt, which is unsupported. + -accessibility ..... Compile Accessibility support. -no-sql- ... Disable SQL entirely. -qt-sql- ... Enable a SQL in the Qt SQL module, by default none are turned on. -plugin-sql- Enable SQL as a plugin to be linked to at run time. Possible values for : [ db2 ibase mysql oci odbc psql sqlite sqlite2 tds ] -system-sqlite ..... Use sqlite from the operating system. -no-javascript-jit . Do not build the JavaScriptCore JIT compiler. + -javascript-jit .... Build the JavaScriptCore JIT compiler. -no-qml-debug ...... Do not build the in-process QML debugging support. + -qml-debug ......... Build the QML debugging support. -platform target ... The operating system and compiler you are building on (linux-g++). See the README file for a list of supported operating systems and compilers. -no-sse2 ........... Do not compile with use of SSE2 instructions. -no-sse3 ........... Do not compile with use of SSE3 instructions. -no-ssse3 .......... Do not compile with use of SSSE3 instructions. -no-sse4.1 ......... Do not compile with use of SSE4.1 instructions. -no-sse4.2 ......... Do not compile with use of SSE4.2 instructions. -no-avx ............ Do not compile with use of AVX instructions. -no-avx2 ........... Do not compile with use of AVX2 instructions. -no-neon ........... Do not compile with use of NEON instructions. -no-mips_dsp ....... Do not compile with use of MIPS DSP instructions. -no-mips_dspr2 ..... Do not compile with use of MIPS DSP rev2 instructions. -qtnamespace Wraps all Qt library code in 'namespace {...}'. -qtlibinfix Renames all libQt*.so to libQt*.so. -testcocoon ........ Instrument Qt with the TestCocoon code coverage tool. -D ........ Add an explicit define to the preprocessor. -I ........ Add an explicit include path. -L ........ Add an explicit library path. + -pkg-config ........ Use pkg-config to detect include and library paths. By default, configure determines whether to use pkg-config or not with some heuristics such as checking the environment variables. -no-pkg-config ..... Disable use of pkg-config. -force-pkg-config .. Force usage of pkg-config (skips pkg-config usability detection heuristic). -help, -h .......... Display this information. Third Party Libraries: -qt-zlib ........... Use the zlib bundled with Qt. + -system-zlib ....... Use zlib from the operating system. See -no-gif ............ Do not compile GIF reading support. -no-libpng ......... Do not compile PNG support. -qt-libpng ......... Use the libpng bundled with Qt. + -system-libpng ..... Use libpng from the operating system. See -no-libjpeg ........ Do not compile JPEG support. -qt-libjpeg ........ Use the libjpeg bundled with Qt. + -system-libjpeg .... Use libjpeg from the operating system. See -no-openssl ........ Do not compile support for OpenSSL. + -openssl ........... Enable run-time OpenSSL support. -openssl-linked .... Enabled linked OpenSSL support. -qt-pcre ........... Use the PCRE library bundled with Qt. + -system-pcre ....... Use the PCRE library from the operating system. -qt-xcb ............ Use xcb- libraries bundled with Qt. (libxcb.so will still be used from operating system). + -system-xcb ........ Use xcb- libraries from the operating system. -qt-xkbcommon ...... Use the xkbcommon library bundled with Qt. + -system-xkbcommon .. Use the xkbcommon library from the operating system. Additional options: -make ....... Add part to the list of parts to be built at make time. (defaults to: libs tools examples) -nomake ..... Exclude part from the list of parts to be built. -skip ..... Exclude an entire module from the build. -no-compile-examples ... Install only the sources of examples. -no-gui ............ Don't build the Qt GUI module and dependencies. + -gui ............... Build the Qt GUI module and dependencies. -no-widgets ........ Don't build the Qt Widgets module and dependencies. + -widgets ........... Build the Qt Widgets module and dependencies. -R ........ Add an explicit runtime library path to the Qt libraries. -l ........ Add an explicit library. -no-rpath .......... Do not use the library install path as a runtime library path. + -rpath ............. Link Qt libraries and executables using the library install path as a runtime library path. Equivalent to -R install_libpath -continue .......... Continue as far as possible if an error occurs. -verbose, -v ....... Print verbose information about each step of the configure process. -silent ............ Reduce the build output so that warnings and errors can be seen more easily. * -no-optimized-qmake ... Do not build qmake optimized. -optimized-qmake ...... Build qmake optimized. -no-nis ............ Do not compile NIS support. * -nis ............... Compile NIS support. -no-cups ........... Do not compile CUPS support. * -cups .............. Compile CUPS support. Requires cups/cups.h and libcups.so.2. -no-iconv .......... Do not compile support for iconv(3). * -iconv ............. Compile support for iconv(3). -no-icu ............ Do not compile support for ICU libraries. + -icu ............... Compile support for ICU libraries. -no-strip .......... Do not strip binaries and libraries of unneeded symbols. * -strip ............. Strip binaries and libraries of unneeded symbols when installing. -no-pch ............ Do not use precompiled header support. * -pch ............... Use precompiled header support. -no-dbus ........... Do not compile the Qt D-Bus module. + -dbus .............. Compile the Qt D-Bus module and dynamically load libdbus-1. -dbus-linked ....... Compile the Qt D-Bus module and link to libdbus-1. -reduce-relocations ..... Reduce relocations in the libraries through extra linker optimizations (Qt/X11 and Qt for Embedded Linux only; experimental; needs GNU ld >= 2.18). -force-asserts ........ Force Q_ASSERT to be enabled even in release builds. -device ............... Cross-compile for device (experimental) -device-option ... Add device specific options for the device mkspec (experimental) * -no-separate-debug-info . Do not store debug information in a separate file. -separate-debug-info .... Strip debug information into a separate file. -no-xcb ............ Do not compile Xcb (X protocol C-language Binding) support. * -xcb ............... Compile Xcb support. -no-eglfs .......... Do not compile EGLFS (EGL Full Screen/Single Surface) support. * -eglfs ............. Compile EGLFS support (Requires OpenGL ES 2 support). -no-directfb ....... Do not compile DirectFB support. * -directfb .......... Compile DirectFB support. -no-linuxfb ........ Do not compile Linux Framebuffer support. * -linuxfb ........... Compile Linux Framebuffer support. -no-kms ............ Do not compile KMS support. * -kms ............... Compile KMS support (Requires EGL and OpenGL ES 2 support). -qpa ......... Sets the default QPA platform (e.g xcb, cocoa, windows). -xplatform target ... The target platform when cross-compiling. -sysroot ...... Sets as the target compiler's and qmake's sysroot and also sets pkg-config paths. -no-gcc-sysroot ..... When using -sysroot, it disables the passing of --sysroot to the compiler -no-feature- Do not compile in . -feature- .. Compile in . The available features are described in src/corelib/global/qfeatures.txt -qconfig local ...... Use src/corelib/global/qconfig-local.h rather than the default (full). -no-opengl .......... Do not support OpenGL. -opengl ....... Enable OpenGL support With no parameter, this will attempt to auto-detect OpenGL ES 2, or regular desktop OpenGL. Use es2 for to override auto-detection. * -no-system-proxies .. Do not use system network proxies by default. -system-proxies ..... Use system network proxies by default. -no-warnings-are-errors Make warnings be treated normally -warnings-are-errors Make warnings be treated as errors (enabled if -developer-build is active) -no-glib ........... Do not compile Glib support. + -glib .............. Compile Glib support. + cd .. + qtbase/bin/qmake /opt/tools/qt-everywhere-opensource-src-5.1.1

运行 ./configureQt配置默认安装目录为 /usr/local/Qt-5.1.1 ,(你也可以使用-prefix 选项来指定自己的配置安装目录):
root@ubuntu:/opt/tools/qt-everywhere-opensource-src-5.1.1# ./configure 

+ cd qtbase

+ /opt/tools/qt-everywhere-opensource-src-5.1.1/qtbase/configure 

Which edition of Qt do you want to use ?

Type 'c' if you want to use the Commercial Edition.

Type 'o' if you want to use the Open Source Edition.

o

This is the Qt Open Source Edition.

You are licensed to use this software under the terms of

the Lesser GNU General Public License (LGPL) versions 2.1.

Type 'L' to view the Lesser GNU General Public License version 2.1.

Type 'yes' to accept this license offer.

Type 'no' to decline this license offer.

Do you accept the terms of the license? yes(选择“yes”,Enter)

开始配置过程,然而却发现配置失败:
 The test for linking against libxcb and support libraries failed!
 You might need to install dependency packages, or pass -qt-xcb.
 See src/plugins/platforms/xcb/README.

查看源码的
README:
root@ubuntu:/opt/tools/qt-everywhere-opensource-src-5.1.1# vim README
......
New dependencies in Qt 5
   ------------------------
     Linux: On systems running X11, the XCB libraries are required for
     the platform plugin to build. qtbase/src/plugins/platforms/xcb/README
     lists the required packages.

可知在linux上运行X11需要XCB libraries,而qtbase/src/plugins/platforms/xcb/README文件清楚地列出所有要安装的依赖包:
root@ubuntu:/opt/tools/qt-everywhere-opensource-src-5.1.1# vim qtbase/src/plugins/platforms/xcb/README
On Ubuntu 12.04 icccm1 is replaced by icccm4 and xcb-render-util can be installed automatically: libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync0 libxcb-sync0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0 libxcb-render-util0-dev libxcb-glx0-dev
安装所有依赖包:
root@ubuntu:/opt/tools/qt-everywhere-opensource-src-5.1.1# vim qtbase/src/plugins/platforms/xcb/README
root@ubuntu:/opt/tools/qt-everywhere-opensource-src-5.1.1# apt-get install libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync0 libxcb-sync0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-render-util0 libxcb-render-util0-dev libxcb-glx0-dev
安装完之后,再重新配置:
root@ubuntu:/opt/tools/qt-everywhere-opensource-src-5.1.1# ./configure

配置成功之后,执行make编译(这个过程比较久):

root@ubuntu:/opt/tools/qt-everywhere-opensource-src-5.1.1# make

如果你用-prefix指定了配置安装目录, 那么你需要运行make install安装 library, examples, tools, and tutorials等到你指定的目录:

root@ubuntu:/opt/tools/qt-everywhere-opensource-src-5.1.1# make install

安装完成之后可以看到:

root@ubuntu:/opt/tools/qt-everywhere-opensource-src-5.1.1# ls /usr/local/Qt-5.1.1
bin examples include mkspecs plugins translations doc imports lib phrasebooks qml

Step 4: Set the Environment Variables

使用 Qt 还需要配置一些环境变量:

PATH - to locate qmake, moc and other Qt tools

打开/etc/profile:

root@ubuntu:/opt/tools/qt-everywhere-opensource-src-5.1.1# vim /etc/profile

在文件最后添加以下环境变量:

PATH=/usr/local/Qt-5.1.1/bin:$PATH export PATH

执行使环境变量生效:

root@ubuntu:/opt/tools/qt-everywhere-opensource-src-5.1.1# source /etc/profile

运行qmake -v,查看Qt的版本

root@ubuntu:/opt/tools/qt-everywhere-opensource-src-5.1.1# qmake -v
QMake version 3.0
Using Qt version 5.1.1 in /usr/local/Qt-5.1.1/lib

完成以上所有步骤之后,Qt就已经成功安装了。


阅读(5748) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~