Yuzuki Lizard V851S开发板 –移植 QT5.12.9教程
-
- 本文转载自:https://forums.100ask.net/t/topic/3027
(群友Blev提供)
移植 QT5 教程 (此教程基于docker版V851S开发环境)
docker pull registry.cn-hangzhou.aliyuncs.com/gloomyghost/yuzukilizard
编译依赖
apt-get install repo git gcc-arm-linux-gnueabihf u-boot-tools device-tree-compiler mtools \ parted libudev-dev libusb-1.0-0-dev python-linaro-image-tools linaro-image-tools libssl-dev \ autotools-dev libsigsegv2 m4 libdrm-dev curl sed make binutils build-essential gcc g++ bash \ patch gzip bzip2 perl tar cpio python unzip rsync file bc wget libncurses5 libglib2.0-dev \ openssh-client lib32stdc++6 gcc-aarch64-linux-gnu libncurses5-dev lzop libssl1.0.0 libssl-dev \ libglade2-dev cvs mercurial subversion asciidoc w3m dblatex graphviz python-matplotlib \ libc6:i386 texinfo liblz4-tool genext2fs expect autoconf intltool libqt4-dev libgtk2.0-dev
安装第一遍会有报错,部分无法执行。在执行一遍,就可以了。
1.建议新建一个docker避免环境污染的问题。
2.打开下面目录
/root/tina-v853-docker/platform/thirdparty/gui/qt/
并解压
tar -xvf qt-5.12.9.tar.xz
3.导入编译工具链
3.1 新建tool文件夹
mkdir /root/tool
3.2 将toolchain.tar解压到tool文件夹下面
cd /root/tool/ tar -xvf toolchain.tar
4.source 编译工具链
4.1 修改profile
vi /etc/profile
增加一行代码
export PATH=$PATH:/root/tool/toolchain/bin
4.2 增加环境变量
nano /root/.bashrc
增加二行代码
export PATH=$PATH:/root/tool/toolchain/bin export STAGING_DIR=$STAGING_DIR:/root/tool/toolchain/bin
5.qt解压完成后,进入文件夹
cd /root/tina-v853-docker/platform/thirdparty/gui/qt/qt-5.12.9/
在当前文件夹里面创建一个.sh文件
执行touch make.sh chmod 777 make.sh nano make.sh
复制粘贴下面内容到文件里面
#!/bin/sh PWD=`pwd` mkdir arm-qt ./configure \ -prefix $PWD/arm-qt \ -release \ -opensource \ -shared \ -xplatform linux-arm-gnueabi-g++ \ -optimized-qmake \ -pch \ -qt-sqlite \ -qt-libjpeg \ -qt-libpng \ -qt-zlib \ -no-opengl \ -skip qt3d \ -skip qtcanvas3d \ -skip qtpurchasing \ -skip qtlocation \ -skip qttools \ -no-sse2 \ -no-openssl \ -no-cups \ -no-glib \ -no-dbus \ -no-xcb \ -no-iconv \ -no-separate-debug-info \ -no-fontconfig \ -recheck-all \ -make examples make -j16 make install
这里面比较复杂,里面开启和关闭部分项目是为了保证编译可以成功。
如果需要编译复杂的QT可以自己测试。
6.将工具链改为自己的
执行:
nano /root/tina-v853-docker/platform/thirdparty/gui/qt/qt-5.12.9/qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf # # qmake configuration for building with arm-linux-gnueabi-g++ # MAKEFILE_GENERATOR = UNIX CONFIG += incremental QMAKE_INCREMENTAL_STYLE = sublib include(../common/linux.conf) include(../common/gcc-base-unix.conf) include(../common/g++-unix.conf) CROSS_COMPILE=arm-openwrt-linux # modifications to g++.conf QMAKE_CC = $${CROSS_COMPILE}-gcc QMAKE_CXX = $${CROSS_COMPILE}-g++ QMAKE_LINK = $${CROSS_COMPILE}-g++ QMAKE_LINK_SHLIB = $${CROSS_COMPILE}-g++ # modifications to linux.conf QMAKE_AR = $${CROSS_COMPILE}-ar cqs QMAKE_OBJCOPY = $${CROSS_COMPILE}-objcopy QMAKE_NM = $${CROSS_COMPILE}-nm -P QMAKE_STRIP = $${CROSS_COMPILE}-strip load(qt_config)
7.编译QT5
执行:
cd /root/tina-v853-docker/platform/thirdparty/gui/qt/qt-5.12.9/
执行:
./make.sh
8.安装
如果没有报错,就编译完成了。
make install
9.下载build文件
执行:
tar -cvf arm-qt.tar arm-qt
压缩包压缩好,就可以通过ftp下载下来了。
10.编译qtdemo
10.1 编译qtdemo
创建一个文件夹helloworld,然后再文件夹里面创建一个文件 main.cpp#include <QApplication> #include <QWidget> #include <QLabel> #include <QSlider> #include <QHBoxLayout> int main(int argc, char **argv) { QApplication app(argc, argv); QWidget *window = new QWidget; window->setWindowTitle("I am a slider"); QLabel *label = new QLabel; // QLabel控件,用于显示数字 QSlider *slider = new QSlider(Qt::Horizontal); // 滑动条 slider->setRange(0, 100); QObject::connect(slider, SIGNAL(valueChanged(int)), label, SLOT(setNum(int))); slider->setValue(50); QHBoxLayout *layout = new QHBoxLayout; //level layout->addWidget(label); layout->addWidget(slider); window->setLayout(layout); window->resize(400, 240); window->show(); return app.exec(); }
10.2 编译
执行:/root/tina-v853-docker/platform/thirdparty/gui/qt/qt-5.12.9/arm-qt/bin/qmake -project
执行:
/root/tina-v853-docker/platform/thirdparty/gui/qt/qt-5.12.9/arm-qt/bin/qmake
执行:
make
此时会提示报错:修改.pro结尾的文件,末尾增加一行代码。
参考这个代码
###################################################################### # Automatically generated by qmake (3.1) Sun Apr 2 23:32:59 2023 ###################################################################### TEMPLATE = app TARGET = helloworld INCLUDEPATH += . # The following define makes your compiler warn you if you use any # feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 # Input SOURCES += hello.cpp greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
并重新执行一遍
10.3 下载可执行文件 helloworld
11.导入
/root/tina-v853-docker/platform/thirdparty/gui/qt/qt-5.12.9/arm-qt/bin
下面的两个文件夹到板子上,其余的不用
复制bin下面的lib 到usr/lib 并根据报错相应的修改文件名
复制bin下面的plugin到usr目录下面
复制刚才的可执行文件helloworld 到/mnt12.进入板子/mnt
添加权限 chmod 777 helloworld
执行./helloworld
13.此时会报错,要修改文件名
凡是涉及到5.12.9.so的文件名,全部要改成5.so 否则会报错
(如何快速改文件名呢?)
其中包含名字为core,gui,widget的,一定要改链接文本 - 本文转载自:https://forums.100ask.net/t/topic/3027
-
@bayche
Hi.
Could tell me please, where can I get "toolchain.tar", becouse when I runtar -xvf toolchain.tar
I get an error
root@344f52882cc0:~/tina-v853-docker/platform/thirdparty/gui/qt# mkdir /root/tool root@344f52882cc0:~/tina-v853-docker/platform/thirdparty/gui/qt# cd /root/tool/ root@344f52882cc0:~/tool# tar -xvf toolchain.tar tar: toolchain.tar: Cannot open: No such file or directory tar: Error is not recoverable: exiting now
thanks for any help
Copyright © 2023 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号