Qt交叉编译环境安装笔记

7 篇文章 0 订阅

要在Qt Creator2.7.1环境中搭建Arm-Linux的交叉编译环境,首先需要明白以下概念:

1.首先使用交叉编译工具链交叉编译 qt库。
2.然后在 QtCreator的 Qt Versions 中添加这个交叉编译的 qt。
有了compiler 和 qt 库 就可以交叉编译了

注意:kits = compiler +  Qt Version; compiler 和  Qt Version 要对应,是同一平台的。

 

 

以下是交叉编译arm版qt库的方法(转载自他人):

编译 arm 版的qt

因为项目需要,我们需要在开发板上使用QT开发平台,因此需要编译一个arm版的QT. 在网上找了一些资料,费了几天时间,终于成功了。

第一步,准备源码

先下载QT 源码,在http://qt-project.org/downloads页面,找到Qt libraries 4.8.6 for embedded Linux (230 MB)(Info), down 下来,拷贝到linux系统下。

解压缩,tar -xzvf qt-everywhere-opensource-src-4.8.6.tar.gz

qt 源码将被解压到qt-everywhere-opensource-src-4.8.6下。


第二步,准备编译器

然后安装交叉编译器,我们的arm 平台编译器已经安装好,安装在 /usr/local/arm/ 目录下。

为了使QT 配置程序能找到我们的编译器,必须把交叉编译器所在的目录放到PATH环境变量上。

请查看另一篇博客《ubuntu10.04安装交叉编译器

第三步,配置,编译,安装

然后到QT的源码所在目录下,

再进到qws目录下

cd mkspecs/qws

ls 看一下,有一个适合我们的配置,就是linux-arm-gnueabi-g++ ,如果没有,就自己建一个目录,然后从别的目录下拷贝这两个文件

qmake.conf 

qplatformdefs.h
进入到linux-arm-gnueabi-g++目录,看一下qmake.conf 的内容,如下:

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++

# modifications to linux.conf
QMAKE_AR                = arm-none-linux-gnueabi-ar cqs
QMAKE_OBJCOPY           = arm-none-linux-gnueabi-objcopy
QMAKE_STRIP             = arm-none-linux-gnueabi-strip

正确,我们就使用这个配置,如果不正确,可以改成自己的编译器的名字。


接下来配置QT, 在QT的源码目录下有一个可执行程序 configure, 运行./configure --help 可以看到详细的配置选项,

为了操作方便,可以写一个脚本文件,文容如下

./configure \
-embedded arm \
-xplatform qws/linux-arm-gnueabi-g++ \
-release \
-opensource  \
-fast  \
-stl \
-no-accessibility  \
-no-scripttools  \
-no-mmx  \
-no-multimedia  \
-no-svg  \
-no-3dnow  \
-no-sse  \
-no-sse2  \
-no-libmng  \
-no-libtiff  \
-no-multimedia  \
-silent  \
-qt-libpng  \
-qt-libjpeg  \
-make libs  \
-nomake tools \
-nomake examples \
-nomake docs  \
-nomake demos \
-nomake translations \
-no-nis \
-no-cups \
-no-iconv  \
-no-dbus  \
-no-openssl  \
-little-endian \
-qt-freetype  \
-depths all \
-qt-gfx-linuxfb  \
-no-gfx-transformed  \
-no-gfx-multiscreen  \
-no-gfx-vnc  \
-no-gfx-qvfb  \
-qt-kbd-linuxinput  \
-no-glib  \
-no-phonon \
-no-phonon-backend \
-no-webkit \
-no-javascript-jit \
-no-sql-db2  \
-no-sql-ibase \
-no-sql-mysql \
-no-sql-oci \
-no-sql-odbc \
-no-sql-psql \
-no-sql-sqlite \
-no-sql-sqlite2 \
-no-sql-sqlite_symbian \
-no-sql-symsql  \
-no-sql-tds \
-no-qt3support \
-qt-mouse-linuxinput \
-no-mouse-tslib \
-no-mouse-linuxtp \
-no-script \
-no-largefile

保存,取名了qt.config.sh

这个配置几乎把QT裁剪到了最小尺寸,运行此脚本,生成Makefile,

然后make, 这个过程很慢,请耐心等待。

然后make install, QT 库被安装到  /usr/local/Trolltech/QtEmbedded-4.8.6-arm


第四步,测试QT arm 开发环境

QT arm 版已经编译,安装完成。测试一下QT arm 开发环境

设置环境变量

export ARMQDIR=/usr/local/Trolltech/QtEmbedded-4.8.6-arm

export PATH=$ARMQDIR/bin:$PATH

export MANPATH=$ARMQDIR/man:$MANPATH

export LD_LIBRARY_PATH=$ARMQDIR/LIB:$LD_LIBRARY_PATH


执行qmake -v, 显示以下信息

QMake version 2.01a
Using Qt version 4.8.6 in /usr/local/Trolltech/QtEmbedded-4.8.6-arm/lib

执行which qmake, 显示

 /usr/local/Trolltech/QtEmbedded-4.8.6-arm/bin/qmake


编写一个hello world 程序

#include <QApplication>
#include <QDebug>

int main(int argc,char *argv[])
{
        qDebug("Hello, welcome to Qt world!");
        return 0;
}

保存为hello.cpp

执行qmake -project hello.cpp -o hello.pro

生成hello.pro

执行qmake hello.pro

生成Makefile

执行 make, 生成hello.o, hello


这一步遇到一个奇怪的问题,就是如果工作目录下包含了子目录,则运行qmake就会hang在那儿,这不知是不是QT的bug.


第五步,下载到开发板

首先在开发板的linux 系统下建立同名的目录,以便拷贝,

/usr/local/Trolltech/QtEmbedded-4.8.6-arm/lib

然后把/usr/local/Trolltech/QtEmbedded-4.8.6-arm/lib目录下的文件全部拷贝过去,我是打了一个包,然后用tftp传过去的。

然后把 libstdc++.so.6.0.9 和libz.so.1.2.3 传送到开发板的 /usr/local/lib 目录下,

设置环境变量 LD_LIBRARY_PATH 以便使QT 程序能找到相应的库,

export LD_LIBRARY_PATH=/usr/local/Trolltech/QtEmbedded-4.8.6-arm/lib:/usr/local/lib

运行QT测试程序

testgui -qws

lcd 显示屏上显示出一个窗口界面,和在windows开发环境下显示出的界面基本相同。


至此,算是成功了。不过还没有做对触摸屏的支持。



 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
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、付费专栏及课程。

余额充值