2022-12-14 移植Qt Creator helloworld 应用到ARM平台运行过程,我这里用buildroot里面的编译器。

一、在ubuntu上运行可执行文件。

1、ubuntu里面安装qt creator 建立helloworld 工程,点击run就可以运行,运行如下。

2、在ubuntu上运行方法二:同级目录下有build-helloworld-Desktop_Qt_5_12_12_GCC_64bit-Debug,用file helloworld命令可以知道它是x86-64可执行文件,执行./helloworld即可运行。

 3、获得Qt可执行文件方法三:
      除了上面说的在Qt Creator 中构建出可以在ARM平台上运行的Qt程序之外,还有另一种方法也可以得到可以运行的Qt程序。进入项目的文件夹,直接运行qmake,生成 Makefile,再执行 make 开始编译。

     3.1 到工程目录下执行qmake,可能会遇到

qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory

 解决方法是:执行sudo vim /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf 在里面添加qt安装的路径就可以运行。

二、接下来如何交叉编译helloworld了,然后放到ARM上运行。

1、我这里用buildroot编译出来output目录下的编译器进行编译,qmake、make之后就生成ARM可执行文件。

 

 2、把可执行文件helloworld放到arm板上面运行

  3、上图可以看到运行的时候会有error的提示。官方发布的 Buildroot 固件,默认已支持 Wayland 桌面环境以及一些 Qt 应用,解决方案是执行下面:

export XDG_RUNTIME_DIR=/tmp/.xdg
./helloworld -platform  wayland
qt.qpa.plugin: Could not find the Qt platform plugin "eglfs" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: linuxfb, minimal, offscreen, vnc, wayland-egl, wayland.

   4、出现上面的error可以设置下面的两个变量指定显示屏就可以打开了应用

		export QT_QPA_PLATFORM=wayland
		export XDG_RUNTIME_DIR=/tmp/.xdg

 5、真机运行效果,mipi屏幕。

三、buildroot系统,在桌面上显示helloworld图标,点击打开应用

1、/usr/share/applications目录下是在桌面显示图标的应用,模仿一个qhelloworld.desktop用来打开qhelloworld

2、qhelloworld.desktop内容

[Desktop Entry]
Name=qhelloworld
Exec=/usr/bin/helloworld
Icon=/usr/share/icon/icon_qsetting.png
Type=Application

 3、mipi 屏幕显示效果

四、参考文章

linux下arm平台Qt编译环境搭建与解析 - ldxsuanfa - 博客园

移植Qt到ARM平台及搭建Qt交叉编译环境_<阿杰。>的博客-CSDN博客_qt arm

快速解决qmake编译错误:could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory_Uka Saegusa IN db的博客-CSDN博客

执行QT程序时刚启动提示Could not find the Qt platform plugin "eglfs" in "" / 全志 SOC / WhyCan Forum(哇酷开发者社区)

猜你喜欢

转载自blog.csdn.net/qq_37858386/article/details/128318333