交叉编译Qt5.7

0.1 准备

     (1) 安装交叉编译链,我使用的为:arm-linux-gnueabihf-gcc
    (2) 交叉编译tslib,我使用的为厂家编译好的tslib,如果使用电阻式触摸屏必须使用tslib。

    (3) 下载Qt5.7源码包

     http://download.qt.io/official_releases/qt/5.7/5.7.0/submodules/qt-everywhere-opensource-src-5.7.0.tar.gz

1.1 安装Qtcreator

      (1) 下载地址

      http://mirrors.ustc.edu.cn/qtproject/archive/qt/5.8/5.8.0/qt-opensource-linux-x64-5.8.0.run

      (2) 以root身份运行安装程序,并安装到合适的目录(/opt或/usr/local)

1.2 解压

      tar -zxvf /home/chy/qianRuShi/ziliao/qt/qt-everywhere-opensource-src-5.7.0.tar.gz -C /opt/Qt5.8.0/5.8/

1.3 拷贝编译器配置文件

      cp ./qtbase/mkspecs/linux-arm-gnueabi-g++ ./qtbase/mkspecs/linux-arm-gnueabihf-g++ -r

1.4 修改qmake.conf

      vim ./qtbase/mkspecs/linux-arm-gnueabihf-g++/qmake.conf

      内容如下:

交叉编译Qt5.7_第1张图片

图一

1.5 配置并生成Makefile

       ./configure -prefix /opt/Qt5.8.0/5.8/Qt5.7_arm_linuxfs/ -opensource -shared -xplatform linux-arm-gnueabihf-g++ -qt-zlib -tslib -no-opengl -nomake examples -skip qtcanvas3d -I/opt/tslib/include -L/opt/tslib/lib -skip qt3d -qreal float -qt-libpng -qt-libjpeg -make libs -skip qtdeclarative

1.6 模块清单

   
Configure summary


Building on:   linux-g++ (x86_64, CPU features: mmx sse sse2)
Building for:  linux-arm-gnueabihf-g++ (arm, CPU features: none detected)
Platform notes:


            - Also available for Linux: linux-clang linux-kcc linux-icc linux-cxx
        
Build options:
  Configuration .......... accessibility audio-backend c++11 clock-gettime clock-monotonic compile_examples concurrent cross_compile dbus doubleconversion enable_new_dtags evdev eventfd freetype full-config getaddrinfo getifaddrs harfbuzz iconv inotify ipv6ifname large-config largefile linuxfb medium-config minimal-config mremap nis no-pkg-config pcre png poll_ppoll posix_fallocate precompile_header qpa qpa reduce_exports release rpath shared small-config threadsafe-cloexec tslib zlib 
  Build parts ............  libs
  Mode ................... release
  Using sanitizer(s)...... none
  Using C++ standard ..... c++11
  Using gold linker....... no
  Using new DTAGS ........ yes
  Using PCH .............. yes
  Using LTCG ............. no
  Target compiler supports:
    Neon ................. no


Qt modules and options:
  Qt D-Bus ............... yes (loading dbus-1 at runtime)
  Qt Concurrent .......... yes
  Qt GUI ................. yes
  Qt Widgets ............. yes
  Large File ............. yes
  QML debugging .......... yes
  Use system proxies ..... no


Support enabled for:
  Accessibility .......... yes
  ALSA ................... no
  CUPS ................... no
  DoubleConversion........ yes (bundled copy)
  Evdev .................. yes
  FontConfig ............. no
  FreeType ............... yes (bundled copy)
  Glib ................... no
  GStreamer .............. no
  GTK platformtheme ...... no
  HarfBuzz ............... yes (bundled copy)
  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)
  libinput................ no
  Logging backends: 
    journald ............... no
    syslog   ............... no
  mtdev .................. no
  Networking: 
    getaddrinfo .......... yes
    getifaddrs ........... yes
    IPv6 ifname .......... yes
    libproxy.............. no
    OpenSSL .............. no
  NIS .................... yes
  OpenGL / OpenVG: 
    EGL .................. no
    OpenGL ............... no
    OpenVG ............... no
  PCRE ................... yes (bundled copy)
  pkg-config ............. no 
  PulseAudio ............. no
  QPA backends: 
    DirectFB ............. no
    EGLFS ................ no
      EGLFS i.MX6 ........ no
      EGLFS i.MX6 Wayland. no
      EGLFS EGLDevice .... no
      EGLFS GBM .......... no
      EGLFS Mali ......... no
      EGLFS Raspberry Pi . no
      EGLFS X11 .......... no
    LinuxFB .............. yes
    Mir client............ no
    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
  tslib .................. yes
  udev ................... no
  xkbcommon-x11........... no
  xkbcommon-evdev......... no
  zlib ................... yes (bundled copy)


1.7 编译并安装

     make

     make install

2.1 修改tslib的ts.conf文件,如下:

# Uncomment if you wish to use the linux input layer event interface
# module_raw input


# Uncomment if you're using a Sharp Zaurus SL-5500/SL-5000d
# module_raw collie


# Uncomment if you're using a Sharp Zaurus SL-C700/C750/C760/C860
# module_raw corgi


# Uncomment if you're using a device with a UCB1200/1300/1400 TS interface
# module_raw ucb1x00


# Uncomment if you're using an HP iPaq h3600 or similar
# module_raw h3600


# Uncomment if you're using a Hitachi Webpad
# module_raw mk712


# Uncomment if you're using an IBM Arctic II
# module_raw arctic2


module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear


2.2 拷贝tslib库到开发板(可以通过vsftp传到开发板或制作根文件系统)

     (1) 打包后通过vsftp传到开发板。
     (2) 解压
          tar -zxvf ./tslib.tar.zip
     (3) 复制tslib/etc/ts.conf到开发板的/etc
         cp ./tslib/etc/ts.conf /etc
     (4) 复制tslib/bin/下的所有文件到开发板的/usr/bin/
        cp ./tslib/bin/* /usr/bin/
     (5) 复制tslib/lib/下的所有文件到开发板的/usr/lib/
        cp -r ./tslib/lib/* /usr/lib/

    (6) 配置环境变量,打开/etc/profile文件,并添加如下内容:

       export TSLIB_PLUGINDIR=/usr/lib/ts/
       export TSLIB_TSDEVICE=/dev/input/event0
       export TSLIB_CALIBFILE=/etc/pointercal
       export TSLIB_CONFFILE=/etc/ts.conf
       export LD_LIBRARY_PATH=/usr/lib

2.3 拷贝Qt5.7的库到开发板(可以通过vsftp传到开发板或制作根文件系统)

    (1) 打包后通过vsftp上传到开发板

    (2) 解压 

        tar -zxvf ./lib.tar.zip

    (3) 复制./lib下的所有文件到/usr/lib目录下
        cp -r ./lib/* /usr/lib

    (4) 配置环境变量,打开/etc/profile文件,并添加如下内容:

       export QT_QWS_FONTDIR=/usr/lib/fonts
       export QWS_MOUSE_PROTO=/dev/input/event0
       export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/qt-plugins
       export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0
       export QT_QPA_FONTDIR=/usr/lib/fonts

3.1 配置刚刚编译的Qt5.7

    (1) 进入Qtcreator的工具->选项->构建和运行

交叉编译Qt5.7_第2张图片

图二

   (2) 进入添加编译器,选择[添加]->[GCC]->[C++]

交叉编译Qt5.7_第3张图片

图三

   (3) 添加[c]和调试器[gdb]参考第二步

   (4) [Qt Versions]->[添加]

交叉编译Qt5.7_第4张图片

图四

   (5) [kit] -> [添加],使用刚才添加的gcc、g++、gdb。

交叉编译Qt5.7_第5张图片

图五

3.2 测试

交叉编译Qt5.7_第6张图片
图六

====================================================================================================================================
可能遇到的问题
  出现如下问题时安装libiconv
   QIconvCodec::convertToUnicode: using Latin-1 for conversion, iconv_open failed
   QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv_open failed
  (1) 下载链接:
      https://ftp.gnu.org/gnu/libiconv/
  (2) 配置并安装安装
     echo "CC=arm-linux-gnueabihf-gcc"
    ./configure --prefix=/home/chy/out  --host=arm-linux-gnueabihf
    make
    make install
   (3) 复制preloadable_libiconv.so到开发板的/lib目录,并配置在/etc/profile添加export LD_PRELOAD=/lib/preloadable_libiconv.so

  出现如下问题时添加-skip qtdeclarative参数
   ProjectERROR: Unknownmodule(s)inQT:quick
   make[2]: *** [sub-virtualkeyboard-make_first] Error3














你可能感兴趣的:(嵌入式系统)