交叉编译QT源码
第一步:
下载qt源码:https://download.qt.io/archive/qt/
下载交叉编译工具链(我是用的RK3588官方SDK提供的工具链)。
第二步:
将源码和交叉编译工具链解压到一个文件夹中
shen@shen-VirtualBox:~/qt$ ls
prebuilts qt-everywhere-src-5.12.5
prebuilts.tar.gz qt-everywhere-src-5.12.5.tar
其中prebuilts是交叉编译工具链,qt-everywhere-src-5.12.5是下载好的qt源码。
进入qt源码目录,看看源码结构,然后创建一个build.sh脚本备用。
shen@shen-VirtualBox:~/qt$ cd qt-everywhere-src-5.12.5/
shen@shen-VirtualBox:~/qt/qt-everywhere-src-5.12.5$ mkdir build.sh
shen@shen-VirtualBox:~/qt/qt-everywhere-src-5.12.5$ ls
build.sh qtactiveqt qtscript
_clang-format qtandroidextras qtscxml
coin qtbase qtsensors
config.cache qtcanvas3d qtserialbus
config.log qtcharts qtserialport
config.opt qtconnectivity qtspeech
config.status qtdatavis3d qtsvg
config.summary qtdeclarative qttools
config.tests qtdoc qttranslations
configure qtgamepad qtvirtualkeyboard
configure.bat qtgraphicaleffects qtwayland
configure.json qtimageformats qtwebchannel
gnuwin32 qtlocation qtwebengine
LICENSE.FDL qtmacextras qtwebglplugin
LICENSE.GPLv2 qtmultimedia qtwebsockets
LICENSE.GPLv3 qtnetworkauth qtwebview
LICENSE.LGPLv21 qt.pro qtwinextras
LICENSE.LGPLv3 qtpurchasing qtx11extras
LICENSE.QT-LICENSE-AGREEMENT-4.0 qtquickcontrols qtxmlpatterns
Makefile qtquickcontrols2 README
qt3d qtremoteobjects
shen@shen-VirtualBox:~/qt/qt-everywhere-src-5.12.5$
更改脚本权限:
shen@shen-VirtualBox:~/qt/qt-everywhere-src-5.12.5$ chmod +x build.sh
进入qtbase/mkspecs/下
shen@shen-VirtualBox:~/qt/qt-everywhere-src-5.12.5$ cd qtbase/mkspecs/
根据自己的交叉编译工具链创建一个文件夹,我创建的文件夹叫aarch64-none-linux-gnu-g++,然后将linux-arm-gnueabi-g++文件夹下的内容全部复制到刚刚创建的文件夹下。
shen@shen-VirtualBox:~/qt/qt-everywhere-src-5.12.5/qtbase/mkspecs/$ mkdir aarch64-none-linux-gnu-g++
shen@shen-VirtualBox:~/qt/qt-everywhere-src-5.12.5/qtbase/mkspecs/$ cp ./linux-arm-gnueabi-g++/* ./aarch64-none-linux-gnu-g++/
修改aarch64-none-linux-gnu-g++/文件夹下的qmake.conf
vim qmke.conf
将框内的内容修改成自己的编译工具链的绝对路径就行。
第三步:
进入到qt源码的根目录,编辑最先创建的build.sh文件:
-prefix为安装的路径
-xplatform 为qtbase/mkspecs/下创建的aarch64-none-linux-gnu-g++文件夹
-I/opt/qt5.12.5/include/ 和-L/opt/qt5.12.5/lib/根据安装路径修改。
第四步:
build.sh
没报错的话:
make -j8 //这一过程可能需要很久
make install //make install可能需要root权限
在opt下就能看到安装好的qt
root@shen-VirtualBox:/opt# ls
qt5 VBoxGuestAdditions-7.0.2
root@shen-VirtualBox:/opt# cd qt5/
root@shen-VirtualBox:/opt/qt5# ls
bin doc examples include lib mkspecs phrasebooks plugins qml translations
root@shen-VirtualBox:/opt/qt5#
未完待续…