想要把qt工程放到开发板上运行,就需要用到交叉编译。由于qt是跨平台的,所以只需要换个编译器编译一下就可以。
以qt学习–计时器的例子为例,在移植之前还需要进行一个准备工作,在windows下运行的时候,电脑屏幕很大,但是运行的窗口只有一点点大,开发板也有外接屏幕,如何让运行窗口自动适配开发板的外接屏幕呢?令其占满屏幕显示,而不是一小块。

一、编译生成在开发板上的可执行文件

第一步:需要设置一下,先给ui布局,如果不布局,控件就不会随着屏幕的大小的变化而变化。利用代码来获取屏幕的大小,给widget.cpp文件下添加如下代码

#include <QDesktopWidget>
#include <QStyle>
#include <QRect> QDesktopWidget *deskTopWidget = QApplication::desktop();
QRect deskRect = deskTopWidget->availableGeometry();
int appH = deskRect.height();
int appW = deskRect.width();
this->setFixedSize(appW, appH);
setGeometry(0, 0, appW, appH);

添加完后,编译运行一下,会看到现在运行结果显示框与电脑屏幕一样大。将layoutstrength处的(0,0,0)改成了(5,2,3),可以使得界面更美观。

第二步:用ssh软件把time文件夹传到ubuntu下

root@ubuntu:~# cd /home/qt/
root@ubuntu:/home/qt# ls
qt_source  qt_system
root@ubuntu:/home/qt# mkdir qt_demo
root@ubuntu:/home/qt# ls
qt_demo  qt_source  qt_systemroot@ubuntu:/home/qt# cd qt_demo/
root@ubuntu:/home/qt/qt_demo# ls
time

第三步:删掉.pro.user文件,以免影响后面

root@ubuntu:/home/qt/qt_demo# cd time/
root@ubuntu:/home/qt/qt_demo/time# ls
main.cpp  time.pro  time.pro.user  widget.cpp  widget.h  widget.uiroot@ubuntu:/home/qt/qt_demo/time# rm time.pro.user
root@ubuntu:/home/qt/qt_demo/time#
root@ubuntu:/home/qt/qt_demo/time# ls
main.cpp  time.pro  widget.cpp  widget.h  widget.ui

第四步:执行make

root@ubuntu:/home/qt/qt_demo/time# make
make: *** 没有指明目标并且找不到 makefile。 停止。

显示找不到makefile,需要在命令行写上之前执行脚本文件并执行make以及make install的时候生成的文件的路径,我的在“/usr/local/Qt-5.7.0/bin/qmake ”路径下。

root@ubuntu:/home/qt/qt_demo/time# /usr/local/Qt-5.7.0/bin/qmake
Info: creating stash file /home/qt/qt_demo/time/.qmake.stash

按道理执行完这条路径指令之后应该没有任何提示的,删除生成的makefile重新执行一下

root@ubuntu:/home/qt/qt_demo/time# ls
main.cpp  Makefile  time.pro  widget.cpp  widget.h  widget.ui
root@ubuntu:/home/qt/qt_demo/time# rm Makefile
root@ubuntu:/home/qt/qt_demo/time# /usr/local/Qt-5.7.0/bin/qmake
root@ubuntu:/home/qt/qt_demo/time#
root@ubuntu:/home/qt/qt_demo/time# ls
main.cpp  Makefile  time.pro  widget.cpp  widget.h  widget.ui
root@ubuntu:/home/qt/qt_demo/time# makeroot@ubuntu:/home/qt/qt_demo/time# ls
main.cpp  Makefile        moc_widget.o  time.pro     widget.cpp  widget.o
main.o    moc_widget.cpp  time          ui_widget.h  widget.h    widget.ui

生成time之后,在ubuntu界面再执行一条指令查看一下time的属性,看是否能够在开发板上运行。如果是属于ARM平台的二进制文件,则可以在开发板上执行;如果是x86-64,那就是x86上位机平台文件,不可以在开发板执行。

说明:
鉴于之前在开发板上烧写qt5.7未能成功,就选择使用早之前在开发板上可以运行的qt4.7版本了。

  • 针对qt4.7版本,其qmake文件所在路径为:/opt/qt-4.7.1/bin/qmake
  • 写完路径之后,执行make,如果报错
root@ubuntu:/home/qt/qt_demo/time# make
arm-linux-g++ -Wl,-O1 -Wl,-rpath,/opt/qt-4.7.1/lib -o time main.o widget.o moc_widget.o    -L/opt/qt-4.7.1/lib -lQtGui -L/usr/local/tslib/lib -L/opt/qt-4.7.1/lib -lQtNetwork -lQtCore -lpthread
main.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status
make: *** [time] 错误 1
root@ubuntu:/home/qt/qt_demo/time# ls
main.cpp  Makefile        moc_widget.o  ui_widget.h  widget.h  widget.ui
main.o    moc_widget.cpp  time.pro      widget.cpp   widget.o
root@ubuntu:/home/qt/qt_demo/time# rm Makefile
root@ubuntu:/home/qt/qt_demo/time# /opt/qt-4.7.1/bin/qmake
root@ubuntu:/home/qt/qt_demo/time# ls
main.cpp  Makefile        moc_widget.o  ui_widget.h  widget.h  widget.ui
main.o    moc_widget.cpp  time.pro      widget.cpp   widget.o
root@ubuntu:/home/qt/qt_demo/time# make
arm-linux-g++ -Wl,-O1 -Wl,-rpath,/opt/qt-4.7.1/lib -o time main.o widget.o moc_widget.o    -L/opt/qt-4.7.1/lib -lQtGui -L/usr/local/tslib/lib -L/opt/qt-4.7.1/lib -lQtNetwork -lQtCore -lpthread
main.o: file not recognized: File format not recognized
collect2: ld returned 1 exit status
make: *** [time] 错误 1

解决办法:执行make clean命令,然后再执行make命令

root@ubuntu:/home/qt/qt_demo/time# make clean
rm -f moc_widget.cpp
rm -f ui_widget.h
rm -f main.o widget.o moc_widget.o
rm -f *~ core *.core
root@ubuntu:/home/qt/qt_demo/time# make
root@ubuntu:/home/qt/qt_demo/time# ls
main.cpp  Makefile        moc_widget.o  time.pro     widget.cpp  widget.o
main.o    moc_widget.cpp  time          ui_widget.h  widget.h    widget.ui
root@ubuntu:/home/qt/qt_demo/time# file time
time: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 2.6.14, not stripped

二、开发板上电启动qt系统,执行可执行文件

我选择的是用U盘拷贝可执行文件,然后在超级终端上挂载U盘,执行该可执行文件。

~ # ls /mnt/
disk  usb1
~ # mount /dev/udisk /mnt/usb1/
~ # cd /mnt/usb1/
/mnt/usb1 # ls
1.wav
myPhonon1
myPhonon11
python
scope_0.png
scope_1.png
scope_2.png
scope_3.png
t1110_success.slx
time/mnt/usb1 # time -qws
time: invalid option -- 'q'
BusyBox v1.21.1 (2013-11-02 04:41:24 AMST) multi-call binary.Usage: time [-v] PROG ARGSRun PROG, display resource usage when it exits-v      Verbose/mnt/usb1 # ./time
[  240.998293] hub 1-0:1.0: port 3 disabled by hub (EMI?), re-enabling...
[  241.003575] usb 1-3: USB disconnect, device number 2
[  241.008424] usb 1-3.2: USB disconnect, device number 3
[  241.019297] dm9620 1-3.2:1.0: eth0: unregister 'dm9620' usb-s5p-ehci-3.2, Davicom DM9620 USB Ethernet
[  241.027855] mmc_sd_detect(mmc1): Unable to re-detect card (-123)
[  241.033468] mmc1: card 0001 removed
[  241.115188] dm9620_unbind():
[  241.116630] flg_txdbg  0
[  241.119149] rx_length_errors 0
[  241.125103] rx_over_errors   0
[  241.126708] rx_crc_errors    0
[  241.129745] rx_frame_errors  0
[  241.230112] rx_fifo_errors   0
[  241.231719] rx_missed_errors 0
[  241.310260] usb 1-3.3: USB disconnect, device number 4
[  241.830040] usb 1-3: new high speed USB device number 5 using s5p-ehci
[  241.901373] s5p-ehci s5p-ehci: port 3 reset error -110
[  242.576434] s5p-ehci s5p-ehci: port 3 reset error -110
[  242.850140] *******mmc1: inserted!!!!!******
[  242.939305] mmc1: new high speed SDHC card at address 0001
[  242.955253] mmcblk1: mmc1:0001 SD16G 14.5 GiB
[  242.961626]  mmcblk1: p1 p2 p3 p4
[  243.196451] s5p-ehci s5p-ehci: port 3 reset error -110
[  243.816889] s5p-ehci s5p-ehci: port 3 reset error -110
[  244.436869] s5p-ehci s5p-ehci: port 3 reset error -110
[  244.850336] hub 1-0:1.0: Cannot enable port 3.  Maybe the USB cable is bad?
[  244.911890] s5p-ehci s5p-ehci: port 3 reset error -110
[  245.586859] s5p-ehci s5p-ehci: port 3 reset error -110
[  246.206867] s5p-ehci s5p-ehci: port 3 reset error -110
[  246.826865] s5p-ehci s5p-ehci: port 3 reset error -110
[  247.446869] s5p-ehci s5p-ehci: port 3 reset error -110
[  247.860332] hub 1-0:1.0: Cannot enable port 3.  Maybe the USB cable is bad?
[  247.921888] s5p-ehci s5p-ehci: port 3 reset error -110
[  248.596869] s5p-ehci s5p-ehci: port 3 reset error -110
[  249.216888] s5p-ehci s5p-ehci: port 3 reset error -110
[  249.836890] s5p-ehci s5p-ehci: port 3 reset error -110
[  250.456890] s5p-ehci s5p-ehci: port 3 reset error -110
[  250.870335] hub 1-0:1.0: Cannot enable port 3.  Maybe the USB cable is bad?
[  250.931868] s5p-ehci s5p-ehci: port 3 reset error -110
[  251.606868] s5p-ehci s5p-ehci: port 3 reset error -110
[  252.226889] s5p-ehci s5p-ehci: port 3 reset error -110
[  252.846890] s5p-ehci s5p-ehci: port 3 reset error -110
[  253.466892] s5p-ehci s5p-ehci: port 3 reset error -110
[  253.880497] hub 1-0:1.0: Cannot enable port 3.  Maybe the USB cable is bad?
[  253.886133] hub 1-0:1.0: unable to enumerate USB device on port 3

终于可以在开发板上跑程序啦,哭辽,经历了两天左右的时间呢。给大家浅看一下在开发板上运行的图片。

嵌入式学习之QT学习---14 QT跨平台运行之把QT程序交叉编译到ARM开发板相关推荐

  1. ubuntu下的qt程序移植至ARM开发板

    一.第一步新建一个helloworld  QT工程. 二.使用qmake工具生成Makefile文件 在工程源码文件夹运行qmake   "#/opt/qt-4.7.1/bin/qmake& ...

  2. 对国产板子有阴影这些软硬件开源的ARM开发板可以学习Linux驱动

    对国产板子有阴影?这些软硬件开源的ARM开发板可以学习Linux驱动开发 为了点亮一块MIPI屏幕,我们除了要了解MIPI DSI的工作原理之外,大前提要了解整个MIPI DSI图显系统的组成,更需要 ...

  3. 摄像头在liunx上的QT显示和OK6410 ARM开发板上的使用

    摄像头在liunx上的QT显示和OK6410 ARM开发板上的使用 发布者:旺旺雪饼   时间:2013-01-05 16:56:09 环境: Ubuntu10.04 arm linux OS: 3. ...

  4. Linux学习之ARM开发板连接ubuntu18.04LTS及NFS相关配置

    Linux学习之ARM开发板连接ubuntu18.04LTS及NFS相关配置 第一步:在PC机安装Ubuntu18.04LTS 具体安装步骤参见上一篇文章 第二步:安装arm-linux-gcc交叉编 ...

  5. ARM开发板下Qt实现中文输入法的波折历程

    ** ARM开发板下Qt实现中文输入法的波折历程 ** 在移植软键盘输入法时候,如果用到中文输入法一定会用到数据库,移植的Qt工程运行时如果碰到如下error,一定要看看我的文章,对你会有所帮助!!! ...

  6. arm11 s3c6410 开发板 学习板 工业开发板 比较 国内主流的arm开发板比较

    代理arm11开发板已经几个月了,说下我自己的看法. 我首先用语言描述一下国内主流的arm开发板情况,个人对各个公司开发板的看法,仅代表个人意见,没有针对某个公司的意思,由于6410 的开发难度以及工 ...

  7. 中国嵌入式高端ARM开发板的江湖故事——详细分析国内各家ARM11 S3C6410 开发板的选型以及竞争格局

    // Topic:中国嵌入式高端ARM开发板的江湖故事--详细分析国内各家ARM11 S3C6410 开发板的选型以及竞争格局 //作者:gooogleman //版权:gooogleman  邮箱 ...

  8. 中国嵌入式高端ARM开发板的江湖故事 详细分析国内各家ARM11 S3C6410 开发板的选型以及竞争格局

    分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! // T ...

  9. 电脑向linux板卡传文件,ARM 开发板嵌入式linux系统与主机PC通过串口传输文件

    ARM 开发板嵌入式linux系统与主机PC通过串口传输文件 本来以为按以下两篇文章就可以几步轻松搞定这个问题,没想到遇到两个小麻烦: 1,我用的xp虚拟机下redhat9.0做主机,按照下面第一篇文 ...

最新文章

  1. Windows系统管理大师、畅销书作者William R.Stanek的又一经典力作
  2. 粤桂粤黔协作签约-丰收节交易会·李喜贵:谋定一县一园产业园
  3. SAP ABAP ALV构建动态输出列与构建动态内表
  4. 在Flutter中解析复杂的JSON(一篇顶十篇)
  5. 日志处理两大生态Splunk和ELK深度对比
  6. React.js 小书 Lesson15 - 实战分析:评论功能(二)
  7. hbase中列簇和列_为什么不建议在hbase中使用过多的列簇
  8. 论文浅尝 | 用图网络做小样本学习
  9. python文件替换一行_python自动化替换文件中每一行中的特有字符串
  10. pythoncsv格式列变换_用Python将csv行转换为列
  11. 在java中使用ffmpeg将amr格式的语音转为mp3格式
  12. python中collections模块_Python的collections模块
  13. 刚知道,qq聊天的时候可以这么装逼
  14. 511遇见易语言教程外形框和模仿进度条闪烁效果
  15. 三维扫描3D打印在创客教育中的实际应用
  16. 心中无码便是高清,用“脑补”除马赛克!
  17. 【SDOI2008】Sue的小球
  18. Fiddler - The system proxy was changed. Click to reenable capturing.
  19. OpenWrt实现无线客户端之间的隔离
  20. Python随记(28)爬取碧蓝航线的立绘(狗头)

热门文章

  1. linux中用循环求平均值,怎么用循环句求平均值(在线等)
  2. 开源进度跟踪 33复杂美Chain33
  3. 搭建私人 云笔记+ ftp + joplin
  4. layui获取复选框的值
  5. Java调用微信小程序云数据库 调试记录
  6. python周报第十五周
  7. 特征阻抗(特性阻抗):解析
  8. python 点击屏幕
  9. oracle 取字段长度为5,oracle9i中varchar2(5)字段长度不足5前面补0?
  10. (三)01 -Vue项目打包发布移动App——vue.config.js中配置相对路径publicPath为空字符串 在public中添加HBuilderX的打包配置文件manifest.json