Qt5之海思交叉编译笔记

一、搭建环境

    Win7 + VMware15 + Ubuntu16.04(64位) + Qt5.9.9

    交叉工具链:arm-hisiv500-linux-

二、交叉编译

    1)下载源码 

        http://download.qt.io/archive/qt/

        当前我下载了和我的 Qt 同一个版本的源码 qt-everywhere-opensource-src-5.9.9.tar.xz 。并将其下载到 Linux 系统下,当前我存放在 /home/work/tools/ 目录下。然后解压源码包。

xz -d qt-everywhere-opensource-src-5.9.9.tar.xz
tar -xvf qt-everywhere-opensource-src-5.9.9.tar

        之后就会得到一个 qt-everywhere-opensource-src-5.9.9 的目录 ,之后 cd 进入即可。

    2)配置编译环境

./configure -prefix /opt/qt_hisiv500 -release -opensource -qt-libpng -qt-libjpeg -plugin-sql-sqlite -widgets -no-iconv -no-dbus -no-openssl -no-iconv -no-accessibility -no-sse2 -silent -xplatform linux-arm-gnueabi-g++ -nomake tools -nomake examples -nomake tests -qt-freetype -no-glib -strip -linuxfb -no-opengl

     注意:-prefix 后面这个 /opt/qt_hisiv500 是后面安装的路径,可自行修改 !!!

        以下根据提示输入 y 即可 

 

   3)修改交叉编译器

        当我们配置成功之后 ,当前目录就会有一个 Makefile 文件, 在这文件中搜索 qmake.conf ,这个就是我们需要修改的文件

        上图中我们可以看出 qmake.conf 文件所在的路径,打开这个文件如下图所示

         上图中 arm-linux-gnueabi- 是默认的交叉编译器,我们需要改成自己需要的交叉编译器即可,如下所示

    4)编译

make

 

    5)安装

make install

 

         上图看出在 /opt 目录下多出来一个 qt_hisiv500 的目录

        在 qt_hisiv500/bin 目录下有一个 qmake 工具 ,这个是最常用的,之后会使用这个交叉编译代码,之后就可以在 ARM 板子上运行了。  

三、测试

    1)新建 Qt5 项目

        这个步骤此处省略,当前已经建好Qt工程 ,不一定是 Qt 的界面工程,也可以是 Qt 的纯 C 工程或者是 纯 C++ 工程。

         上图是一个 Qt5 界面工程,可以使用 Qt5 打开并且运行,但是此处使用 qmake 自己编译。

    2)使用 Qt 自带的 qmake 编译工程

        我的 Qt5.9.9 安装在 /opt/Qt5.9.9 目录下,所以自带的 qmake 所在目录如下

    使用Qt5自带的 qmake 生成 Makefile

        在 Qt 工程目录下输入一下命令

/opt/Qt5.9.9/5.9.9/gcc_64/bin/qmake

 

       上图可以看出输入命令之后就有一个 Makefile,这样可以输入 make 编译 Qt 工程了

make

        上图看出编译之后的可执行文件是 untiled ,使用 file 命令看出这是一个运行于 X86 平台的可执行程序,运行结果如下。

    3)使用编译好的交叉工具 qmake 编译 Qt5 工程

        其实和之前使用自带的 qmake 操作一样,生成 Makefile 的步骤如下

/opt/qt_hisiv500/bin/qmake

        同样生成 Makefile 文件,打开 Makefile 可以看出使用 arm-hisiv500-linux- 进行编译的

    make 编译

        上图看出编译之后得到的可执行文件是运行在 ARM 平台的,所以在 Ubuntu 中无法运行。

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
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值