Ubuntu QT 交叉编译环境搭建

下载安装qtCreator

QT下载官网下载对应需要的QT软件。

这里下载5.12.96版本的
在这里插入图片描述

改变安装包权限,然后,sudo运行安装包。
在这里插入图片描述

安装在opt目录下
在这里插入图片描述
安装完成。到安装路径QtCreator的bin目录中 找到应用的开启程序:

在这里插入图片描述
后台运行QtCreator:

/opt/Qt5.12.9/Tools/QtCreator/bin/qtcreator.sh &

在这里插入图片描述

not a valid identifier 的错误

今天上午搭建交叉编译环境,安装arm-linux-gcc时,source /etc/profile的时候,老是跳出“路径 not a valid identifier”,检查了半天也不知道什么原因,后来在网上看到有人说是中英文的问题,我回头检查一看,果然,添加这句“export PATH=$PATH:/usr/local/arm/4.4.3/bin”时,因为是直接复制,黏贴过来的时候,“=”是中文格式,然后我赶紧把里面的符号重新再英文环境下打一遍,果然,安装顺利。顺便附上安装过程:

安装g++

下载并安装交叉编译器

下载交叉编译器

linaro交叉编译器官网上去下载交叉编译器

在这里插入图片描述
挑选自己需要的交叉编译器
在这里插入图片描述
在这里插入图片描述

点击下载,下载速度有点慢,可以找个梯子去下载,会快速很多。


安装交叉编译器

交叉编译器解压缩到/usr/local/arm/目录中。

然后在/etc/profile添加交叉编译器的环境变量。

重启系统查看是否能够显示交叉编译器版本以确定安装成功。

下载编译 ARM 的Qt平台源码

我们可以在 Qt 下载地址 https://download.qt.io/找到 https://download.qt.io/archive/qt/5.12/5.12.9/si
ngle/,进入下载页面如下。

tslib库的安装,

./configure  --host=arm-linux-gnueabi ac_cv_func_malloc_0_nonnull=yes --cache-file=arm-linux.cache -prefix=/home/lonn/tslib-1.21/arm-tslib

上面的-prefix=/home/lonn/tslib-1.21/arm-tslib该为自己的目录,需要创建一个armtslib的文件夹

配置arm的QT平台

要是绝对路径

#
# qmake configuration for building with arm-linux-gnueabi-g++
#

MAKEFILE_GENERATOR      = UNIX
CONFIG                 += incremental
QMAKE_INCREMENTAL_STYLE = sublib

QT_QPA_DEFAULT_PLATFORM = linux
QMAKE_CFLAGS += -O2 -march=armv7-a -mtune=cortex-a7
QMAKE_CXXFLAGS += -O2 -march=armv7-a -mtune=cortex-a7

include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)

# modifications to g++.conf
QMAKE_CC                = /usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc
QMAKE_CXX               = /usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-g++
QMAKE_LINK              = /usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-g++
QMAKE_LINK_SHLIB        = /usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-g++

# modifications to linux.conf
QMAKE_AR                = /usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-ar cqs
QMAKE_OBJCOPY           = /usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy
QMAKE_NM                = /usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-nm -P
QMAKE_STRIP             = /usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-strip
load(qt_config)
#!/bin/sh

./configure -prefix /home/lonn/Desktop/qt-everywhere-src-5.12.9/arm-qt \
-opensource \
-confirm-license \
-release \
-strip \
-shared \
-xplatform linux-arm-gnueabi-g++ \
-optimized-qmake \
-c++std c++11 \
--rpath=no \
-pch \
-skip qt3d \
-skip qtactiveqt \
-skip qtandroidextras \
-skip qtcanvas3d \
-skip qtconnectivity \
-skip qtdatavis3d \
-skip qtdoc \
-skip qtgamepad \
-skip qtlocation \
-skip qtmacextras \
-skip qtnetworkauth \
-skip qtpurchasing \
-skip qtremoteobjects \
-skip qtscript \
-skip qtscxml \
-skip qtsensors \
-skip qtspeech \
-skip qtsvg \
-skip qttools \
-skip qttranslations \
-skip qtwayland \
-skip qtwebengine \
-skip qtwebview \
-skip qtwinextras \
-skip qtx11extras \
-skip qtxmlpatterns \
-make libs \
-make examples \
-nomake tools -nomake tests \
-gui \
-widgets \
-dbus-runtime \
--glib=no \
--iconv=no \
--pcre=qt \
--zlib=qt \
-no-openssl \
--freetype=qt \
--harfbuzz=qt \
-no-opengl \
-linuxfb \
--xcb=no \
-tslib \
--libpng=qt \
--libjpeg=qt \
--sqlite=qt \
-plugin-sql-sqlite \
-I/home/lonn/tslib-1.21/arm-tslib/include \
-L/home/lonn/tslib-1.21/arm-tslib/lib \
-recheck-all

qmake.conf

#
# qmake configuration for building with arm-linux-gnueabi-g++
#

MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib

QT_QPA_DEFAULT_PLATFORM = linuxfb
QMAKE_CFLAGS += -O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard
QMAKE_CXXFLAGS += -O2 -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard


include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)

# modifications to g++.conf
QMAKE_CC = arm-linux-gnueabihf-gcc
QMAKE_CXX = arm-linux-gnueabihf-g++
QMAKE_LINK = arm-linux-gnueabihf-g++
QMAKE_LINK_SHLIB = arm-linux-gnueabihf-g++

# modifications to linux.conf
QMAKE_AR = arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY = arm-linux-gnueabihf-objcopy
QMAKE_NM = arm-linux-gnueabihf-nm -P
QMAKE_STRIP = arm-linux-gnueabihf-strip
load(qt_config)

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值