準備
主機平台:Ubuntu 16.04 LTS(x64)
目标平台:ARM40-A5D3
Qt版本:Qt4.8.7
tslib github
ARM-GCC編譯工具鍊:gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi
交叉編譯工具鍊
下載下傳gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi.tar.xz
gcc.png
安裝ARM-GCC編譯工具鍊
$ sudo xz -d gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi.tar.xz
$ ls
$ sudo tar xvf gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi.tar -C /opt/
1
2
3
編輯.bashrc檔案
$ cd ~
$ vim .bashrc
在.bashrc的末尾添加下面的文本
export PATH=$PATH:/opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/
檢視ARM-GCC版本
$ arm-linux-gnueabi-gcc -v
Thread model: posix
gcc version 4.9.4 (Linaro GCC 4.9-2017.01)
安裝tslib
使用浏覽器下載下傳tslib
下載下傳tslib
使用git下載下傳tslib
$ sudo apt-get install git
$ git clone https://github.com/kergoth/tslib.git
正克隆到 ‘tslib’…
remote: Counting objects: 5089, done.
remote: Total 5089 (delta 0), reused 0 (delta 0), pack-reused 5089
接收對象中: 100% (5089/5089), 2.39 MiB | 429.00 KiB/s, 完成.
處理 delta 中: 100% (3505/3505), 完成.
檢查連接配接… 完成。
編譯tslib
$ sudo apt-get install automake libtool
$ sudo mkdir /opt/tslib
$ cd tslib
$ ./autogen.sh
$ ./configure CC=arm-linux-gnueabi-gcc \
CXX=arm-linux-gnueabi-g++ \
--prefix=/opt/tslib \
--host=arm-linux-gnueabi \
ac_cv_func_malloc_0_nonnull=yes
$ make&&sudo make install
4
5
6
7
8
9
10
編譯報錯
/home/jonny/tslib/libtool: line 10540: arm-linux-gnueabi-gcc: command not found
libtool: error: error: relink ‘linear.la’ with the above command before installing it
Makefile:755: recipe for target ‘install-pluginexecLTLIBRARIES’ failed
make2: * [install-pluginexecLTLIBRARIES] Error 1
make2: Leaving directory ‘/home/jonny/tslib/plugins’
Makefile:1021: recipe for target ‘install-am’ failed
make1: * [install-am] Error 2
make1: Leaving directory ‘/home/jonny/tslib/plugins’
Makefile:483: recipe for target ‘install-recursive’ failed
make: * [install-recursive] Error 1
解決方案
原因:sudo指令使用的是root的環境變量,sudo就找不到ARM-GCC了
解決:添加ARM-GCC的絕對路徑就好了
$ ./configure CC=/opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
CXX=/opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-g++ \
--prefix=/opt/tslib \
--host=arm-linux-gnueabi \
ac_cv_func_malloc_0_nonnull=yes
檢視tslib
$ ls /opt/tslib/
bin etc include lib share
編譯Qt4.8.7
下載下傳qt-everywhere-opensource-src-4.8.7.tar.gz
qt4.8.7
編輯qmake.conf
$ tar xvf qt-everywhere-opensource-src-4.8.7.tar.gz ./
$ cd qt-everywhere-opensource-src-4.8.7/
$ vim ./mkspecs/qws/linux-arm-gnueabi-g++/qmake.conf
#
# qmake configuration for building with arm-none-linux-gnueabi-g++
include(../../common/linux.conf)
include(../../common/gcc-base-unix.conf)
include(../../common/g++-unix.conf)
include(../../common/qws.conf)
# modifications to g++.conf
QMAKE_CC = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc -lts
QMAKE_CXX = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-g++ -lts
QMAKE_LINK = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-g++ -lts
QMAKE_LINK_SHLIB = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-g++ -lts
# modifications to linux.conf
QMAKE_AR = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy
QMAKE_STRIP = /opt/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-strip
load(qt_config)
11
12
13
14
15
16
17
18
19
20
21
configure編譯配置
-debug-and-release \ Qt調試;
-shared \ 動态編譯;
-static \ 靜态編譯;
-make docs \ 文檔幫助;
-DQT_NO_QWS_CURSOR \ 不顯示滑鼠
$ ./configure \
--prefix=/opt/qte4.8.7 \
-opensource \
-debug-and-release \
-shared \
-Declarative \
-fast \
-no-largefile \
-qt-sql-sqlite \
-qt3support \
-exceptions \
-xmlpatterns \
-script \
-scripttools \
-no-glib \
-no-phonon \
-svg \
-no-webkit \
-qt-zlib \
-qt-libtiff \
-qt-libpng \
-qt-libjpeg \
-make libs \
-nomake tools \
-nomake examples \
-make docs \
-nomake demos \
-no-nis \
-no-cups \
-no-iconv \
-no-dbus \
-xplatform qws/linux-arm-gnueabi-g++ \
-embedded arm \
-little-endian \
-qt-freetype \
-depths 16,24,32 \
-qt-gfx-linuxfb \
-no-gfx-transformed \
-no-gfx-multiscreen \
-no-gfx-vnc \
-no-gfx-qvfb \
-qt-kbd-linuxinput \
-qt-kbd-tty \
-no-kbd-qvfb \
-armfpa \
-optimized-qmake \
-no-mouse-qvfb \
-qt-mouse-linuxtp \
-qt-mouse-tslib \
-DQT_QLOCALE_USES_FCVT \
-DQT_NO_QWS_CURSOR \
-pch \
-I/opt/tslib/include \
-L/opt/tslib/lib \
-confirm-license
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
編譯安裝Qt
$ sudo mkdir /opt/qte4.8.7
$ make -j 4
$ sudo make install
make3: Leaving directory ‘/home/jonny/qt-everywhere-opensource-src-4.8.7/tools/linguist/linguist’
make2: Leaving directory ‘/home/jonny/qt-everywhere-opensource-src-4.8.7/tools/linguist’
Makefile:339: recipe for target ‘sub-linguist-make_default-ordered’ failed
make1: * [sub-linguist-make_default-ordered] Error 2
make1: Leaving directory ‘/home/jonny/qt-everywhere-opensource-src-4.8.7/tools’
Makefile:742: recipe for target ‘sub-tools-make_default-ordered’ failed
make: * [sub-tools-make_default-ordered] Error 2
— 解決方案:configure項添加 -nomake tools 或者直接忽視之
Makefile:1054: recipe for target ‘.moc/release-shared-emb-arm/moc_qabstractanimation.cpp’ failed
make1: * [.moc/release-shared-emb-arm/moc_qabstractanimation.cpp] Error 2
make1: * 正在等待未完成的任務….
Makefile:1314: recipe for target ‘.moc/release-shared-emb-arm/moc_qvariantanimation.cpp’ failed
make1: * [.moc/release-shared-emb-arm/moc_qvariantanimation.cpp] Error 2
Makefile:1433: recipe for target ‘.moc/release-shared-emb-arm/moc_qpropertyanimation.cpp’ failed
make1: * [.moc/release-shared-emb-arm/moc_qpropertyanimation.cpp] Error 2
make1: Leaving directory ‘/home/jonny/qt-everywhere-opensource-src-4.8.7/src/corelib’
Makefile:201: recipe for target ‘sub-corelib-make_default-ordered’ failed
make: * [sub-corelib-make_default-ordered] Error 2
解決方案:一般都是編譯器路徑有問題導緻的,檢查qmake.conf檔案
檢視Qt版本
$ cd /opt/qte4.8.7/bin/
$ ./qmake -v
QMake version 2.01a
Using Qt version 4.8.7 in /opt/qte4.8.7/lib
至此,Qt4.8.7交叉編譯完成。
參考引用