一、配置交叉编译工具链
1、交叉编译工具链目录
/opt/zlg/m3568-sdk-v1.0.0-ga/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/bin/aarch64-rockchip-linux-gnu-g++
/opt/zlg/m3568-sdk-v1.0.0-ga/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/bin/aarch64-rockchip-linux-gnu-gcc
2、编辑bashrc
vi ~/.bashrc,在末尾添加
export PATH=/opt/zlg/m3568-sdk-v1.0.0-ga/gcc-buildroot-9.3.0-2020.03-x86_64_aarch64-rockchip-linux-gnu/bin:$PATH
export CROSS_COMPILE=aarch64-rockchip-linux-gnu-
使用source ~/.bashrc来使得修改生效。
二、配置mkspecs
进入目录
/home/zfadmin/Qt5.12.2_src_arm/qt-everywhere-src-5.12.2/qtbase/mkspecs
复制一份使用rockchip的平台
cp -r linux-aarch64-gnu-g++ linux-aarch64-rockchip-gnu
其中linux-aarch64-rockchip-gnu/qmake.conf的内容如下
#
# qmake configuration for building with aarch64-rockchip-linux-gnu-g++
#MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublibinclude(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/g++-unix.conf)# modifications to g++.conf
QMAKE_CC = aarch64-rockchip-linux-gnu-gcc
QMAKE_CXX = aarch64-rockchip-linux-gnu-g++
QMAKE_LINK = aarch64-rockchip-linux-gnu-g++
QMAKE_LINK_SHLIB = aarch64-rockchip-linux-gnu-g++# modifications to linux.conf
QMAKE_AR = aarch64-rockchip-linux-gnu-ar cqs
QMAKE_OBJCOPY = aarch64-rockchip-linux-gnu-objcopy
QMAKE_NM = aarch64-rockchip-linux-gnu-nm -P
QMAKE_STRIP = aarch64-rockchip-linux-gnu-strip
load(qt_config)
三、编译Qt
稍后再单独编译mysql插件
进入主目录,执行如下:
./configure -opensource -confirm-license -nomake tests -nomake examples -release -no-opengl \
-platform linux-g++ -xplatform linux-aarch64-rockchip-gnu \
-prefix /home/zfadmin/armqt-5.12.2_2
make -j8
make install
在armqt-5.12.2_2生成了Qt可执行文件和相关库文件
四、编译Qt的Mysql插件
1、修改mysql.pro
进入目录/home/zfadmin/Qt5.12.2_src_arm/qt-everywhere-src-5.12.2/qtbase/src/plugins/sqldrivers/mysql
编辑mysql.pro文件,其中openssl是在编译Mysql库的时候使用的:
TARGET = qsqlmysql
SOURCES += $$PWD/qsql_mysql.cpp
HEADERS += $$PWD/qsql_mysql_p.h# 包含路径和库路径
INCLUDEPATH += /home/zfadmin/mySQLArmv8Install/include /home/zfadmin/openssl1.0.0_install/include
LIBS += -L/home/zfadmin/mySQLArmv8Install/lib -lmysqlclient
LIBS += -L/home/zfadmin/openssl1.0.0_install/lib -lssl -lcrypto# 线程和其他系统库
LIBS += -lpthread -lm -lrt -ldl# 插件特定配置
QT += sql
CONFIG += plugin
PLUGIN_CLASS_NAME = QMYSQLDriverPlugin# qsqldriverbase.pri 是Qt内部使用的,用于设置基本的SQL驱动配置
include(../qsqldriverbase.pri)
2、qmake
使用刚编译出来的qmake
/home/zfadmin/armqt-5.12.2_2/bin/qmake
3、make及make install
make -j4
make install
可在/home/zfadmin/armqt-5.12.2_2/plugins/sqldrivers 中看到libqsqlmysql.so