五:Qt5.2.1移植,交叉编译环境安装 Ubuntu12.04 32bit 1.下载qt-everywhere-opensource-src-5.2.1.tar.gz源码包 下载arm-linux-gcc-4.4.3.tar.gz包,(arm板编译工具)
配置编译Qt源码包之前需预先安装, g++,opengl,xcb。
2.在线升级安装 sudo apt-get update g++:sudo apt-get install build-essential xcb:sudo 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(可察看README中 Linux: On systems running X11, the XCB libraries are required for the platform plugin to build. qtbase/src/plugins/platforms/xcb) opengl:sudo apt-get install mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev dbus: sudo apt-get install dbus-*dev
: 3.安装arm编译工具arm-linux-gcc: arm-linux-gcc-4.4.3.tar.gz包: 解压sudo tar -xvzf arm-linux-gcc-4.4.3.tar.gz –C /解压后得到/opt/FriendlyARM /目录 添加环境 :将arm-linux-gcc工具链加入环境路径中: 打开sudo gedit /etc/bash.bashrc,在最后一行加入 export PATH=”$PATH:/opt/FriendlyARM/toolschain/4.4.3/bin”保存 使环境变量生效: source /etc/bash.bashrc 检查环境变量是否生效 :echo $PATH 检查arm-linux-gcc是否生效: arm-linux-gcc –v 在ubuntu 64位系统需提前安装32位库,否则arm-linux-gcc –v会失败,sudo apt-get install ia32-libs, 出现错误可以检查执行文件位是否为32-bit file /opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/bin/gcc 然后检查系统是否也为32位:file /bin/ls
4. Qt源码包交叉编译(示例) ——Qt5.0.2以后采用了QPA插件跨平台,也就是说在新版本中qws已经无效,取消了embedded,而是用-xplatform指定目标板配置,以下采用版本5的新方法和QPA进行编译
进入目录: 解压tar -xvzf qt-everywhere-opensource-src-5.2.1.tar.gz 改名mv qt-everywhere-opensource-src-5.2.1 qt-5.2.1-arm cd qt-5.2.1-arm cd ./qtbase/mkspecs 说明:Qt5源码包进行编译所依赖的配置文件在mkspec目录中,本例 configure 交叉编译选项便指定为 –xplatform linux-arm-test 创建新配置目录: 以一个linux-arm-test配置目录为例,将mkspecs目录下的linux-arm-gnueabi-g++复制为linux-arm-test cp linux-arm-gnueabi-g++ linux-arm-test –r 修改linux-arm-test配置 cd linux-arm-test 查看ls /opt/FriendlyARM/toolschain/4.4.3/bin查看目录下实际编译工具链名 将linux-arm-test目录下qmake.config中的arm-linux-gnueabi-开头都更改为实际路径加工具链名:PATH+arm-none-linux-gnueabi- 如QMAKE_CC = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-gcc 再加入三行: QT_QPA_DEFAULT_PLATFORM = linuxfb #qpa图形插件, QMAKE_CFLAGS_RELEASE += -O2 -march=armv5te QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv5te
说明1:QT_QPA_DEFAULT_PLATFORM选项是指定图形插件, Qt5将各平台底层抽象为一个 qpa 插件,通常在mac上是cocoa, 在window上是windows, 在linux X11下是xcb, 如果有OPENGL支持, 那么选eglfs。而对于无硬件加速的设备,则选择linuxfb,。 minimal仅仅是让程序跑通, 不起任何作用 说明2:目标板为新唐N32905U1DN,cpu为arm936ejs,执行arm-linux-gcc –target-help 查看交叉编译器所支持的架构,选择了其中比较接近的一个为armv5te
修改qmake.conf文件: # # qmake configuration for building with arm-linux-gnueabi-g++ # MAKEFILE_GENERATOR = UNIX CONFIG += incremental gdb_dwarf_index QMAKE_INCREMENTAL_STYLE = sublib QT_QPA_DEFAULT_PLATFORM = linuxfb QMAKE_CFLAGS_RELEASE += -O2 -march=armv5te QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv5te include(../common/linux.conf) include(../common/gcc-base-unix.conf) include(../common/g++-unix.conf) # modifications to g++.conf QMAKE_CC = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-gcc QMAKE_CXX = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-g++ QMAKE_LINK = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-g++ QMAKE_LINK_SHLIB = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-g++ # modifications to linux.conf QMAKE_AR = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-ar cqs QMAKE_OBJCOPY = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-objcopy QMAKE_NM = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-nm -P QMAKE_STRIP = /opt/FriendlyARM/toolschain/4.4.3/bin/arm-none-linux-gnueabi-strip load(qt_config)
保存qmake 进入qt-5.2.1-arm目录下 configure配置: 在qt-5.2.1-arm目录下执行 sudo ./configure -prefix $PWD/qtbase -release -opensource -xplatform linux-arm-qt -nomake tests -no-largefile -qt-zlib -no-nis -qt-libpng -qt-libjpeg -qt-freetype (取消配置为 make confclean,make clean,)
配置完成后打印信息为: Running configuration tests... Warning: Disabling pkg-config since PKG_CONFIG_LIBDIR is not set. Warning: Disabling pkg-config since PKG_CONFIG_SYSROOT_DIR is not set. Configure summary Building on: linux-g++ (i386, CPU features:) Building for: linux-arm-qt (arm, CPU features:) Platform notes: - Also available for Linux: linux-kcc linux-icc linux-cxx Build options: Configuration .......... accessibility audio-backend c++11 clock-gettime clock-monotonic compile_examples concurrent cross_compile evdev eventfd freetype full-config getaddrinfo getifaddrs iconv inotify ipv6ifname large-config linuxfb medium-config minimal-config mremap no-harfbuzz no-pkg-config pcre png posix_fallocate precompile_header qpa qpa reduce_exports reduce_relocations release rpath shared small-config zlib Build parts ............ libs examples Mode ................... release Using C++11 ............ yes Using PCH .............. yes Target compiler supports: iWMMXt/Neon .......... no/no Qt modules and options: Qt D-Bus ............... no Qt Concurrent .......... yes Qt GUI ................. yes Qt Widgets ............. yes JavaScriptCore JIT ..... yes (To be decided by JavaScriptCore) QML debugging .......... yes Use system proxies ..... no Support enabled for: Accessibility .......... yes ALSA ................... no CUPS ................... no FontConfig ............. no FreeType ............... qt Iconv .................. yes ICU .................... no Image formats: GIF .................. yes (plugin, using bundled copy) JPEG ................. yes (plugin, using bundled copy) PNG .................. yes (in QtGui, using bundled copy) Glib ................... no GTK theme .............. no Large File ............. no mtdev .................. no Networking: getaddrinfo .......... yes getifaddrs ........... yes IPv6 ifname .......... yes OpenSSL .............. no NIS .................... no OpenGL ................. no OpenVG ................. no PCRE ................... yes (bundled copy) pkg-config ............. no PulseAudio ............. no QPA backends: DirectFB ............. no EGLFS ................ no KMS .................. no LinuxFB .............. yes XCB .................. no Session management ..... yes SQL drivers: DB2 .................. no InterBase ............ no MySQL ................ no OCI .................. no ODBC ................. no PostgreSQL ........... no SQLite 2 ............. no SQLite ............... yes (plugin, using bundled copy) TDS .................. no udev ................... no xkbcommon .............. no zlib ................... yes (bundled copy) NOTE: Qt is using double for qreal on this system. This is binary incompatible against Qt 5.1. Configure with '-qreal float' to create a build that is binary compatible with 5.1. Info: creating cache file /home/kvl/Qt521-arm/qtbase/.qmake.cache Qt is now configured for building. Just run 'make'. Once everything is built, you must run 'make install'. Qt will be installed into /home/kvl/Qt521-arm/qtbase/qtbase Prior to reconfiguration, make sure you remove any leftovers from the previous build.
|