天天看点

ARM40 Ubuntu交叉编译Qt4.8.7

准备

    主机平台: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交叉编译完成。

参考引用