Qt5+Linux 交叉编译移植
- 安装交叉编译器
- 官网上下载Qt5.9.5源码包(.tar.xz)解压。
- 1、tar -xvf xxx.tar.xz
- 2、写脚本qt5config.sh配置configure。touch qt5config.sh
- 3、chmod 777 qt5config.sh
- 4、添加配置参数(Qt5与Qt4参数名字有些不同)
./configure \
-prefix /usr/local/arm/qt5.9.5\
-opensource \
-confirm-license \
-release -shared \
-xplatform linux-arm-gnueabi-g++ \
-optimized-qmake \
-pch \
-sql-sqlite \
-qt-libjpeg \
-qt-zlib \
-qt-libpng \
-qt-freetype \
-tslib \
-linuxfb \
-no-openssl \
-no-glib \
-no-opengl \
-no-sse2 \
-no-opengl \
-no-cups \
-no-separate-debug-info \
-I/usr/local/arm/tslib/include \
-L/usr/local/arm/tslib/lib
注意:最好在执行配置时加上–prefix的参数。脚本文件里面的-prefix可能不识别
./configure --prefix=/xxx/xxx
其中–prefix选项就是配置安装的路径,如果不配置该选项,安装后可执行文件默认放在/usr /local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc,其它的资源文件放在/usr /local/share,比较分散。
- 5、并用vi 查看qt5config.sh内容格式是否正确
- 6、修改qmake.conf
MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib
QT_QPA_DEFAULT_PLATFORM = linuxfb #指定Qt显示驱动方式
QMAKE_CFLAGS_RELEASE += -O2 -march=armv7-a #指定处理器架构
QMAKE_CXXFLAGS_RELEASE += -O2 -march=armv7-a
include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)
# modifications to g++.conf
QMAKE_CC = arm-none-linux-gnueabi-gcc -lts
QMAKE_CXX = arm-none-linux-gnueabi-gcc -lts
QMAKE_LINK = arm-none-linux-gnueabi-gcc -lts
QMAKE_LINK_SHLIB = arm-none-linux-gnueabi-gcc -lts
# modifications to linux.conf
QMAKE_AR = arm-none-linux-gnueabi-ar cqs
QMAKE_OBJCOPY = arm-none-linux-gnueabi-objcopy
QMAKE_NM = arm-none-linux-gnueabi-nm -P
QMAKE_STRIP = arm-none-linux-gnueabi-strip
load(qt_config)
-
make -j8
-
make install -j8
-
解决ubuntu不支持c++11的问题
出现问题:unrecognized command line option “-std=c++11”
升级g++、gcc 版本见https://blog.youkuaiyun.com/liu1055087125/article/details/72888154/
未完待续…必须Linux系统也是64位的,查看命令:uname -a 因为官网对应Linux的qtcreator.run只有64位
Qt5+Linux 源码编译32位环境
tar zxvf qt-everywhere-opensource-src-x.x.x.tar.gz
./configure
./configure -prefix /xxx

如果有几个软件包无法下载:
-
使用 sudo vim /etc/apt/sources.list 修改镜像源。
-
然后执行 sudo apt-get update 更新。
镜像源如下,推荐使用国内源,速度更快。镜像源内容转载自 https://blog.youkuaiyun.com/skyie53101517/article/details/50450989。
官方源
deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
g++更新完成可能会出现更新的图形界面(每次更新是否不询问,选yes)
继续上一步配置

本文详细介绍Qt5在Linux环境下的交叉编译过程,包括安装交叉编译器、配置脚本、修改qmake.conf等关键步骤,以及解决编译过程中遇到的常见问题。
1109

被折叠的 条评论
为什么被折叠?



