QT系统移植教程
QT系统移植教程
qt教程:
http://www.qter.org/portal.php?mod=view&aid=5
下载源码:
http://download.qt.io/archive/qt/5.4/5.4.2/single/
解压源码:
tar -xvf qt-everywhere-opensource-src-5.4.2.tar.xz
改名字:
mv qt-everywhere-opensource-src-5.4.2 qt-5.4.2
帮助信息:
./configure -help > qthelp.txt
拷贝qmake的配置文件,然后编辑新拷贝的配置文件:
cp -a qtbase/mkspecs/linux-arm-gnueabi-g++/ qtbase/mkspecs/linux-arm-g++/
配置文件目录:/home/fengjunhui/Qt/qt-5.4.2/qtbase/mkspecs/linux-arm-g++
vi qmake.confg
修改所有的arm-linux-gnueabi- 为 arm-linux-
QMAKE_CC = arm-linux-gnueabi-gcc
编辑一个配置脚本:config.sh,保存在源码的顶层目录下。
主要是运行命令时的配置选项,配置选项不正确也会导致编译通不过。
#####################################################################
#!/bin/bash
./configure -release \
-opensource \
-confirm-license \
-no-sse2 \
-no-sse3 \
-no-ssse3 \
-no-sse4.1 \
-no-sse4.2 \
-no-avx \
-no-avx2 \
-no-mips_dsp \
-no-mips_dspr2 \
-no-pkg-config \
-qt-zlib \
-qt-libpng \
-qt-libjpeg \
-qt-freetype \
-no-openssl \
-qt-pcre \
-qt-xkbcommon \
-no-glib \
-nomake examples \
-nomake tools \
-nomake tests \
-no-cups \
-no-iconv \
-no-dbus \
-xplatform linux-arm-g++ \
-no-use-gold-linker \
-qreal float
exit
执行配置脚本:./config.sh
配置完成后的信息:
Info: creating super cache file /home/fengjunhui/Qt/qt-5.4.2/.qmake.super
Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into /usr/local/Qt-5.4.2
Prior to reconfiguration, make sure you remove any leftovers from
the previous build.
编译源码:
make 约2小时
sudo make install
注意: 所有便已生成的文件会保存在下面的目录下:
(因为没有--prefix指定输出目录,所以生成的文件在默认的目录下。)
/usr/local/Qt-5.4.2
cd /usr/local/Qt-5.4.2
查看生成的文件:
fengjunhui@ubuntu:/usr/local/Qt-5.4.2$ ls
bin doc imports include lib mkspecs plugins qml translations
移植到开发板:
cp -a /usr/local/Qt-5.4.2/ ~/source/rootfs/usr/local/
修改rootfs文件系统下的profile文件:在最后添加:
export QTDIR=/usr/local/Qt-5.4.2
export QT_QPA_FONTDIR=$QTDIR/lib/fonts
export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins
export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=1024x600:tty=/dev/ttySAC2
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH$QTDIR:$QTDIR/lib
安装Qt集成开发环境:
linux下载:
下载地址:https://download.qt.io/archive/qt/5.4/5.4.2/
名字: qt-opensource-linux-x86-5.4.2.run
wget -c https://download.qt.io/archive/qt/5.4/5.4.2/qt-opensource-linux-x86-5.4.2.run
window下载:
直接点击:
修改权限:
-rwxrw-rw- 1 fengjunhui fengjunhui 560918516 8月 27 18:05 qt-opensource-linux-x86-5.4.2.run*
chmod u+x qt-opensource-linux-x86-5.4.2.run
安装Qt环境
./qt-opensource-linux-x86-5.4.2.run
全部默认....一路next
可能出现:error:GL/gl.h No such file or directory:
安装库 :sudo apt-get install libqt4-dev
添加ARM平台的构建环境:
tools ---> options ---> build&run General配置工程目录:/home/fengjunhui/Qt/qt-project
tools ---> options ---> build&run Qt Version add添加qmake路径: /usr/local/Qt-5.4.2/bin/qmake
tools ---> options ---> build&run Compilers add添加 选择gcc name GCC(ARM32bit)
compile path 路径选择arm-linux-c++
/home/fengjunhui/toolchain/gcc-4.6.4/bin/arm-linux-c++
tools ---> options ---> build&run Kits add 添加:name: ARM Qt5.4.2 GCC 32bit
Device type : Genernic linux device
Compile: GCC(ARM32bit)
编写测试Qt
......
Qt的教程:
README
HOW TO BUILD QT5
================
Synopsis
========
System requirements
------------------
- Perl 5.8 or later
- Python 2.7 or later
- C++ compiler supporting the C++98 standard
For other platform specific requirements,
please see section "Setting up your machine" on:
http://wiki.qt.io/Get_The_Source
Optional requirements
---------------------
- OpenSSL for SSL sockets or HTTPS
- Wayland
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.
Qt 5 can make use of the ICU libraries providing Unicode and Globalization
support (see http://site.icu-project.org/). They are required for building
QtWebKit.
On Linux, they will be auto-detected.
On Windows, they need to be manually installed and the "include" and "lib"
folders of the ICU installation must be appended to the INCLUDE and LIB
environment variables after calling the Windows SDK setup script.
The "bin" folder of the ICU installation should be appended to the PATH
environment variable in order to for the DLLs to be found at run-time.
Linux, Mac:
-----------
cd
./configure -prefix $PWD/qtbase -opensource -nomake tests
make -j 4
Windows:
--------
Open a Windows SDK (7.0, 7.1 or later) command prompt. Ensure that the
following tools can be found in the path:
* Perl version 5.12 or later [http://www.activestate.com/activeperl/]
* Python version 2.7 or later [http://www.activestate.com/activepython/]
* Ruby version 1.9.3 or later [http://rubyinstaller.org/]
cd
configure -prefix %CD%\qtbase -opensource -nomake tests
nmake // jom // mingw32-make
To accelerate the bootstrap of qmake with MSVC, it may be useful to pass
"-make-tool jom" on the configure command line. If you do not use jom,
adding "/MP" to the CL environment variable is a good idea.
More details follow.
Build!
======
A typical `configure; make' build process is used.
Some relevant configure options (see configure -help):
-release Compile and link Qt with debugging turned off.
-debug Compile and link Qt with debugging turned on.
-nomake tests Disable building of tests to speed up compilation
-nomake examples Disable building of examples to speed up compilation
-confirm-license Automatically acknowledge the LGPL 2.1 license.
Example for a release build:
(adjust the `-jN' parameter as appropriate for your system)
./configure -prefix $PWD/qtbase -opensource
make -j4
Example for a developer build:
(enables more autotests, builds debug version of libraries, ...)
./configure -developer-build -opensource
make -j4
See output of `./configure -help' for documentation on various options to
configure.
The above examples will build whatever Qt5 modules have been enabled by
default in the build system.
It is possible to build selected modules with their dependencies by doing
a `make module-
and the modules they depend on:
./configure -prefix $PWD/qtbase -opensource
make -j4 module-qtscript module-qtwebkit
This can save a lot of time if you are only interested in a subset of Qt5.
Hints
=====
The submodule repository qtrepotools contains useful scripts for
developers and release engineers. Consider adding qtrepotools/bin
to your PATH environment variable to access them.
The qt5_tool in qtrepotools has some more features which may be of interest.
Try `qt5_tool --help'.
Building Qt5 from git
=====================
See http://wiki.qt.io/Building_Qt_5_from_Git and README.git
for more information.
See http://wiki.qt.io/Qt_5 for the reference platforms.
Documentation
=============
After configuring and compiling Qt, building the documentation is possible by running
"make docs".
After having built the documentation, you need to install it with the following
command:
make install_docs
The documentation is installed in the path set to $QT_INSTALL_DOCS.
Running "qmake -query" will list the value of QT_INSTALL_DOCS.
Information about Qt 5's documentation is located in qtbase/doc/README
or in the following page: http://wiki.qt.io/Qt5DocumentationProject
Note: Building the documentation is only tested on desktop platforms.
Qt帮助信息:
+ cd qtbase
+ /home/fengjunhui/Qt/qt-5.4.2/qtbase/configure -top-level -help
Usage: configure [options]
Installation options:
These are optional, but you may specify install directories.
-prefix
-extprefix
-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 EXTPREFIX)
You may use these to separate different parts of the install:
-bindir
-hostbindir
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.
-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-
-qt-sql-
none are turned on.
-plugin-sql-
at run time.
Possible values for
[ db2 ibase mysql oci odbc psql sqlite sqlite2 tds ]
-system-sqlite ..... Use sqlite from the operating system.
-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 (default detected from host system).
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-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
-qtlibinfix
-testcocoon ........ Instrument Qt with the TestCocoon code coverage tool.
-gcov .............. Instrument Qt with the GCov code coverage tool.
-D
-I
-L
+ -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 http://www.gzip.org/zlib
-no-mtdev ......... Do not compile mtdev support.
+ -mtdev ............. Enable mtdev support.
+ -no-journald ....... Do not send logging output to journald.
-journald .......... Send logging output to journald.
-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 http://www.libpng.org/pub/png
-no-libjpeg ........ Do not compile JPEG support.
-qt-libjpeg ........ Use the libjpeg bundled with Qt.
+ -system-libjpeg .... Use libjpeg from the operating system.
See http://www.ijg.org
-no-freetype ....... Do not compile in Freetype2 support.
-qt-freetype ....... Use the libfreetype bundled with Qt.
+ -system-freetype.... Use the libfreetype provided by the system (enabled if -fontconfig is active).
See http://www.freetype.org
-no-harfbuzz ....... Do not compile HarfBuzz-NG support.
* -qt-harfbuzz ....... Use HarfBuzz-NG bundled with Qt to do text shaping.
It can still be disabled by setting
the QT_HARFBUZZ environment variable to "old".
-system-harfbuzz ... Use HarfBuzz-NG from the operating system
to do text shaping. It can still be disabled
by setting the QT_HARFBUZZ environment variable to "old".
See http://www.harfbuzz.org
-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.
-xkb-config-root ... Set default XKB config root. This option is used only together with -qt-xkbcommon.
-qt-xkbcommon ...... Use the xkbcommon library bundled with Qt.
+ -system-xkbcommon .. Use the xkbcommon library from the operating system.
-no-xinput2 ........ Do not compile XInput2 support.
* -xinput2 ........... Compile XInput2 support.
-no-xcb-xlib........ Do not compile Xcb-Xlib support.
* -xcb-xlib........... Compile Xcb-Xlib support.
-no-glib ........... Do not compile Glib support.
+ -glib .............. Compile Glib support.
-no-pulseaudio ..... Do not compile PulseAudio support.
+ -pulseaudio ........ Compile PulseAudio support.
-no-alsa ........... Do not compile ALSA support.
+ -alsa .............. Compile ALSA support.
-no-gtkstyle ....... Do not compile GTK theme support.
+ -gtkstyle .......... Compile GTK theme support.
Additional options:
-make
(defaults to: libs tools examples)
-nomake
-skip
-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
libraries.
-l
-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-evdev .......... Do not compile support for evdev.
* -evdev ............. Compile support for evdev.
-no-icu ............ Do not compile support for ICU libraries.
+ -icu ............... Compile support for ICU libraries.
-no-fontconfig ..... Do not compile FontConfig support.
+ -fontconfig ........ Compile FontConfig support.
-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).
-no-use-gold-linker ..... Do not link using the GNU gold linker.
+ -use-gold-linker ........ Link using the GNU gold linker if available.
-force-asserts ........ Force Q_ASSERT to be enabled even in release builds.
-device
-device-option
(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.
-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).
-qpa
-xplatform target ... The target platform when cross-compiling.
-sysroot
-no-feature-
-feature-
are described in src/corelib/global/qfeatures.txt
-qconfig local ...... Use src/corelib/global/qconfig-local.h rather than the
default (full).
-qreal [double|float] typedef qreal to the specified type. The default is double.
Note that changing this flag affects binary compatibility.
-no-opengl .......... Do not support OpenGL.
-opengl
With no parameter, this will attempt to auto-detect
OpenGL ES 2.0 and higher, or regular desktop OpenGL.
Use es2 for
* -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)
QNX/Blackberry options:
-no-slog2 .......... Do not compile with slog2 support.
-slog2 ............. Compile with slog2 support.
-no-pps ............ Do not compile with pps support.
-pps ............... Compile with pps support.
-no-imf ............ Do not compile with imf support.
-imf ............... Compile with imf support.
-no-lgmon .......... Do not compile with lgmon support.
-lgmon ............. Compile with lgmon support.
MacOS/iOS options:
-Fstring ........... Add an explicit framework path.
-fw string ......... Add an explicit framework.
* -framework ......... Build Qt as a series of frameworks and
link tools against those frameworks.
-no-framework ...... Do not build Qt as a series of frameworks.
-sdk
one of the available SDKs as listed by 'xcodebuild -showsdks'.
Note that the argument applies only to Qt libraries and applications built
using the target mkspec - not host tools such as qmake, moc, rcc, etc.
Android options:
-android-sdk path .............. The Android SDK root path.
(default $ANDROID_SDK_ROOT)
-android-ndk path .............. The Android NDK root path.
(default $ANDROID_NDK_ROOT)
-android-ndk-platform .......... Sets the android platform
(default android-9)
-android-ndk-host .............. Sets the android NDK host (linux-x86, linux-x86_64, etc.)
(default $ANDROID_NDK_HOST)
-android-arch .................. Sets the android architecture (armeabi, armeabi-v7a, x86, mips)
(default armeabi-v7a)
-android-toolchain-version ..... Sets the android toolchain version
(default 4.8)
-no-android-style-assets ....... Do not compile in the code which automatically extracts
style assets from the run-time device. Setting this will
make the Android style behave incorrectly, but will enable
compatibility with the LGPL2.1 license.
* -android-style-assets .......... Compile the code which automatically extracts style assets
from the run-time device. This option will make the
Android platform plugin incompatible with the LGPL2.1.