交叉编译ARM版 Qt

交叉编译ARM版 Qt (qt-everywhere-opensource-src-4.7.3) .

分类: QT   261人阅读  评论(0)  收藏  举报
   因实际项目需求,需将Qt编译成LINUX-ARM版,以下为整个操作过程,使用Qt编写的程序已在实际开发板上运行,在此贴出,但愿能为需要的朋友提供上帮助。

 

准备工作:
Linux内核版本:   
        Linux 2.6.35-22-generic #33-Ubuntu
 交叉编译工具:
        arm-none-linux-gnueabi 4.4.1
 Qt安装包:
        qt-everywhere-opensource-src-4.7.3.tar.gz

安装
一.安装交叉编译工具
 1.本机使用的交叉编译工具是:arm-none-linux-gnueabi 
   
 2.添加交叉编译工具的路径至相应环境变量中:
   export PATH=/usr/CodeSourcery/Sourcery_G++_Lite/bin/:$PATH
   
 3.通过以下命令查看arm-none-linux-gnueabi编译工具是否安装成功
   a. 执行:arm-none-linux-gnueabi-g++ -v
   b. 执行:arm-none-linux-gnueabi-gcc -v
   如果以上两步都能正确打印对应的版本信息,则表明arm-none-linux-gnueabi编译工具
   已安装成功!

   
二.交叉编译ARM版Qt
 1.下载Qt源码包 qt-everywhere-opensource-src-4.7.3.tar.gz;
 
 2.解压Qt源码包
   tar -xvfz qt-everywhere-opensource-src-4.7.3.tar.gz
 
 3.修改文件: /usr/local/qt-4.7.3-linux-arm/mkspecs/qws/linux-arm-g++/qmake.conf  //这个就是解压目录下的mkspecs目录下的内容。用mini2440 的文件不需要更改。sno_guo ++
   
   # 设置交叉编译工具链:
   # 本项目使用的交叉编译工具是 arm-none-linux-gnueabi-g++
   #
   QMAKE_CC                         = arm-none-linux-gnueabi-gcc
   QMAKE_CXX                      = arm-none-linux-gnueabi-g++
   QMAKE_LINK                      = arm-none-linux-gnueabi-g++
   QMAKE_LINK_SHLIB        = arm-none-linux-gnueabi-g++ 
   
   QMAKE_AR                   = arm-none-linux-gnueabi-ar cqs
   QMAKE_OBJCOPY      = arm-none-linux-gnueabi-objcopy
   QMAKE_STRIP             = arm-none-linux-gnueabi-strip
   
 4.(如有需要,需修改g++.conf文件)
   修改文件: /usr/local/qt-4.7.3-linux-arm/mkspecs/common/g++.conf
 
   # 设置使用ARM高级特性的编译标志:
   #
   QMAKE_CFLAGS_RELEASE += -O2 -march=armv7-a -mtune=cortex-a9 -mfloat-abi=softfp
 
 5.配置Qt编译选项
   
   进入Qt解压目录,执行如下命令:
   ./configure -prefix /usr/local/qt-4.7.3-linux-arm-install -embedded arm -host-little-endian -no-cups -no-3dnow -nomake examples -nomake demos -nomake docs -xplatform /qws/linux-arm-g++
   
 6.执行 make 命令;
   该步骤大致需要2~3个小时
 
 7.执行 make install 命令;
   
 8.修改用户环境变量     //把这几条更改下 放到/root/.bashrc 和~/.bashrc文件中。增加完后,要source一下  sno_guo++
   export ARMQTDIR=/usr/local/qt-4.7.3-linux-arm-install
   export PATH=$ARMQTDIR/bin:$PATH
   export MANPATH=$ARMQTDIR/man:$MANPATH  //mini2440删除了man,这里去掉。
   export LD_LIBRARY_PATH=$ARMQTDIR/lib:$LD_LIBRARY_PATH


 9.测试 ARM 版 QT 是否安装并配置成功:
    a. 执行:qmake -v
        打印以下对应信息:
                QMake version 2.01a
                Using Qt version 4.7.3 in /usr/local/qt-4.7.3-linux-arm-install/lib
    b. 执行:which qmake
                打印以下对应信息:
                 /usr/local/qt-4.7.3-linux-arm-install/bin/qmake
 
    c. 编写一个简单的测试程序,文件名为hello.cpp,进入该文件目录,进行工程编译,看是否能正确通编译
  
         hello.cpp源码:
         #include <QApplication>
         #include <QDebug>
         int main(int argc,char *argv[]) 
        {
            qDebug("Hello, welcome to Qt world!");
            return 0;
         }
  
  顺序执行以下操作:
  @1. 执行:qmake -project hello1.cpp
        生成 hello1.pro 工程文件
  @2. 执行:qmake hello1.pro
        生成 Makefile 文件 
  @3. 执行:make
        生成 hello.o, hello 文件 
  
       如果执行@2步骤时出现以下错误:
           QMAKESPEC has not been set, so configuration cannot be deduced.
           Error processing project file: hello1.pro
       则是 QMAKESPEC 变量没有设置好,执行:
      export QMAKESPEC=/usr/local/qt-4.7.3-linux-arm-install/mkspecs/qws/linux-arm-g++
  
    如果以上对应的信息都能正确打印,说明 ARM 版 QT 安装并配置成功,大功告成,可以你的ARM版QT之旅了!\


============================以上为转载别人的======================================================

下面是自己实验过的 在QT creator上直接交叉编译QT

1,tools>options>Build&Run >Qt Versions手动把QT-arm版本的qmake增加进去。
我这里增加的是:/usr/local/Trolltech/QtEmbedded-4.6.3-arm/bin/qmake 点击应用,返回即可!
2,如想编译arm版本的执行文件,QT Creator的左侧中间位置有:Projects选项,点击开,选择上设置的那个QT版本,我这里选择Qt 4.6.3(QtEmbedded-4.6.3-arm) Release
3,如果在编译中出错说 arm-linux-g++ 命令没有找到,则: 
前提是已经配置好交叉编译器,但是qt creator找不到。
解决方法:
修改 /usr/local/Trolltech/QtEmbedded-4.6.3-arm/mkspecs/qws/linux-arm-g++ 路径下的qmake.conf文件
把以下部分:
QMAKE_CC                = arm-linux-gcc
QMAKE_CXX               = arm-linux-g++
QMAKE_LINK              = arm-linux-g++
QMAKE_LINK_SHLIB        = arm-linux-g++


改为:
QMAKE_CC                = /opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-gcc
QMAKE_CXX               = /opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-g++
QMAKE_LINK              = /opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-g++
QMAKE_LINK_SHLIB        = /opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-g++

Building on: linux-g++ (x86_64, CPU features: mmx sse sse2) Building for: linux-aarch64-gnu-g++ (arm64, CPU features: neon) Target compiler: gcc 6.3.1 Configuration: cross_compile use_gold_linker compile_examples enable_new_dtags largefile neon precompile_header shared rpath release c++11 c++14 concurrent dbus reduce_exports stl Build options: Mode ................................... release Optimize release build for size ........ no Building shared libraries .............. yes Using C standard ....................... C11 Using C++ standard ..................... C++14 Using ccache ........................... no Using gold linker ...................... yes Using new DTAGS ........................ yes Using precompiled headers .............. yes Using LTCG ............................. no Target compiler supports: NEON ................................. yes Build parts ............................ libs Qt modules and options: Qt Concurrent .......................... yes Qt D-Bus ............................... yes Qt D-Bus directly linked to libdbus .... no Qt Gui ................................. yes Qt Network ............................. yes Qt Sql ................................. yes Qt Testlib ............................. yes Qt Widgets ............................. yes Qt Xml ................................. yes Support enabled for: Using pkg-config ....................... yes udev ................................... no Using system zlib ...................... yes Qt Core: DoubleConversion ....................... yes Using system DoubleConversion ........ no GLib ................................... no iconv .................................. yes ICU .................................... no Tracing backend ........................ Logging backends: journald ............................. no syslog ............................... no slog2 ................................ no Using system PCRE2 ..................... no Qt Network: getifaddrs() ........................... yes IPv6 ifname ............................ yes libproxy ............................... no Linux AF_NETLINK ....................... yes OpenSSL ................................ yes Qt directly linked to OpenSSL ........ no OpenSSL 1.1 ............................ no DTLS ................................... yes SCTP ................................... no Use system proxies ..................... yes Qt Gui: Accessibility .......................... yes FreeType ............................... yes Using system FreeType ................ no HarfBuzz ............................... yes Using system HarfBuzz ................ no Fontconfig ............................. no Image formats: GIF .................................. yes ICO .................................. yes JPEG ................................. yes Using system libjpeg ............... yes PNG .................................. yes Using system libpng ................ no EGL .................................... no OpenVG ................................. no OpenGL: Desktop OpenGL ....................... no OpenGL ES 2.0 ........................ no OpenGL ES 3.0 ........................ no OpenGL ES 3.1 ........................ no OpenGL ES 3.2 ........................ no Vulkan ................................. no Session Management ..................... yes Features used by QPA backends: evdev .................................. yes libinput ............................... no INTEGRITY HID .......................... no mtdev .................................. no tslib .................................. no xkbcommon .............................. no X11 specific: XLib ................................. no EGL on X11 ........................... no QPA backends: DirectFB ............................... no EGLFS .................................. no LinuxFB ................................ yes VNC .................................... yes Mir client ............................. no Qt Sql: SQL item models ........................ yes Qt Widgets: GTK+ ................................... no Styles ................................. Fusion Windows Qt PrintSupport: CUPS ................................... no Qt Sql Drivers: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. no OCI (Oracle) ........................... no ODBC ................................... no PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no Qt Testlib: Tester for item models ................. yes Qt SerialBus: Socket CAN ............................. yes Socket CAN FD .......................... yes Qt QML: QML network support .................... yes QML debugging and profiling support .... yes QML sequence object .................... yes QML list model ......................... yes QML XML http request ................... yes QML Locale ............................. yes QML delegate model ..................... yes Qt Quick: Direct3D 12 ............................ no AnimatedImage item ..................... yes Canvas item ............................ yes Support for Qt Quick Designer .......... yes Flipable item .......................... yes GridView item .......................... yes ListView item .......................... yes TableView item ......................... yes Path support ........................... yes PathView item .......................... yes Positioner items ....................... yes Repeater item .......................... yes ShaderEffect item ...................... yes Sprite item ............................ yes Qt Scxml: ECMAScript data model for QtScxml ...... yes Qt Gamepad: SDL2 ................................... no Qt 3D: Assimp ................................. yes System Assimp .......................... no Output Qt3D Job traces ................. no Output Qt3D GL traces .................. no Use SSE2 instructions .................. no Use AVX2 instructions .................. no Aspects: Render aspect ........................ yes Input aspect ......................... yes Logic aspect ......................... yes Animation aspect ..................... yes Extras aspect ........................ yes Qt 3D Renderers: OpenGL Renderer ........................ yes Qt 3D GeometryLoaders: Autodesk FBX ........................... no Qt Wayland Client ........................ no Qt Wayland Compositor .................... no Qt Bluetooth: BlueZ .................................. no BlueZ Low Energy ....................... no Linux Crypto API ....................... no WinRT Bluetooth API (desktop & UWP) .... no Qt Sensors: sensorfw ............................... no Qt Quick Controls 2: Styles ................................. Default Fusion Imagine Material Universal Qt Quick Templates 2: Hover support .......................... yes Multi-touch support .................... yes Qt Positioning: Gypsy GPS Daemon ....................... no WinRT Geolocation API .................. no Qt Location: Qt.labs.location experimental QML plugin . yes Geoservice plugins: OpenStreetMap ........................ yes HERE ................................. yes Esri ................................. yes Mapbox ............................... yes MapboxGL ............................. no Itemsoverlay ......................... yes QtXmlPatterns: XML schema support ..................... yes Qt Multimedia: ALSA ................................... no GStreamer 1.0 .......................... no GStreamer 0.10 ......................... no Video for Linux ........................ yes OpenAL ................................. no PulseAudio ............................. no Resource Policy (libresourceqt5) ....... no Windows Audio Services ................. no DirectShow ............................. no Windows Media Foundation ............... no Qt Tools: QDoc ................................... no Qt WebEngine: Embedded build ......................... yes Pepper Plugins ......................... no Printing and PDF ....................... no Proprietary Codecs ..................... no Spellchecker ........................... yes Native Spellchecker .................... no WebRTC ................................. no Use System Ninja ....................... no Geolocation ............................ yes WebChannel support ..................... yes Use v8 snapshot ........................ yes Kerberos Authentication ................ no Building v8 snapshot supported ......... yes Use ALSA ............................... no Use PulseAudio ......................... no Optional system libraries used: re2 .................................. no icu .................................. no libwebp, libwebpmux and libwebpdemux . no opus ................................. no ffmpeg ............................... no libvpx ............................... no snappy ............................... no glib ................................. no zlib ................................. yes minizip .............................. no libevent ............................. no jsoncpp .............................. no protobuf ............................. no libxml2 and libxslt .................. no lcms2 ................................ no png .................................. no JPEG ................................. no harfbuzz ............................. no freetype ............................. no x11 .................................. no Required system libraries: fontconfig ........................... no dbus ................................. no nss .................................. no khr .................................. no glibc ................................ yes Required system libraries for qpa-xcb: libdrm ............................... no xcomposite ........................... no xcursor .............................. no xi ................................... no xrandr ............................... no xtst ................................. no Note: Also available for Linux: linux-clang linux-icc
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值