温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

树莓派如何实现Qt5交叉编译移植

发布时间:2021-11-20 09:42:28 来源:亿速云 阅读:136 作者:小新 栏目:互联网科技

这篇文章主要介绍了树莓派如何实现Qt5交叉编译移植,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

Raspberry Pi (BCM2835): Device Information

ArchitectureARMv6
CPUARM11
RAM256MB OR 512MB since October 2012 (shared with GPU)
GPUVideoCore IV
OpenGLOpenGL ES 2.0
MultimediaOpenMax IL 1.1.2
Qt 5.0 (eglfs/QPA)Supported, with OpenGL ES 2.0

Qt 5 port functional state (against Raspbian Wheezy (primary reference platform))

FeatureStateAdditional info
Hardware accelerated cursorDoneupstream
Wayland supportDoneupstream
Hardware decoding of imagesTo Do
Scenegraph tailoringTo Do
HardFP supportDoneRequires v8 patch
Qt MultimediaDoneRequires gst-omx
Webkit integrationTo Dowebgl, tex mapper
  • 开始

    首先我们先创建一个目录来存放Qt5的源代码以及交叉编译所需要的所有文件,我选择在当前用户家目录下创建一个叫做“opt”的目录。

    1diveinedu@debian :~$ mkdir  ~/opt
    2diveinedu@debian :~$ cd  ~/opt

    然后,下载以下文件:

    下载Raspbian Wheezy 镜像  (这里下载 [raspberrypi.org]):

    1diveinedu@debian :~/opt$ wget  http://downloads.raspberrypi.org/images/raspbian/2013-02-09-wheezy-raspbian/2013-02-09-wheezy-raspbian.zip
    2diveinedu@debian :~/opt$unzip  2013-02-09-wheezy-raspbian.zip

    下载解压完后挂载镜像:

    1diveinedu@debian :~/opt$ sudo  mkdir  /mnt/rasp-pi-rootfs
    2diveinedu@debian:~/opt$ sudo mount  -o loop,offset=62914560 2013-03-09-wheezy-raspbian.img    /mnt/rasp-pi-rootfs

    我们这不介绍交叉工具链的编译,直接下载针对树莓派优化定制的交叉编译工具链(或者用github上树莓派的工具链https://github.com/raspberrypi/tools):

    1diveinedu@debian:~/opt$  wget  http://blueocean.qmh-project.org/gcc-4.7-linaro-rpi-gnueabihf.tbz
    2diveinedu@debian:~/opt$   tar -xf gcc-4.7-linaro-rpi-gnueabihf.tbz

    因为上面的交叉编译工具是32位Linux的,如果你所使用的是64位Linux的话,还需要安装32位的运行库软件包:

    1diveinedu@debian:~/optsudo apt-get install ia32-libs

    如果用的是Debian Wheezy的64位系统,上面的行不通,因为Debian Wheezy 64位开启了multiarch-support ,需要执行:

    1diveinedu@debian:~/opt$  sudo apt-get install multiarch-support
    2diveinedu@debian:~/opt$  sudo dpkg --add-architecture i386
    3diveinedu@debian:~/opt$  sudo apt-get update
    4diveinedu@debian:~/opt$  sudo apt-get install ia32-libs

     

    从远程仓库克隆一份cross-compile-tools到本地:

    1diveinedu@debian:~/opt$  git clone git://gitorious.org/cross-compile-tools/cross-compile-tools.git

    从远程仓库克隆一份Qt5的源码库到本地:

    1diveinedu@debian:~/opt$  git clone git://gitorious.org/qt/qt5.git
    2diveinedu@debian:~/opt$   cd qt5
    3diveinedu@debian:~/opt/qt5$  ./init-repository

    最后,把qtjsbackend子项目打补丁让其支持armv6指令集的树莓派:

    1diveinedu@debian:~/opt/qt5cd ~/opt/qt5/qtjsbackend
    2diveinedu@debian:~/opt/qt5$  git fetch https://codereview.qt-project.org/p/qt/qtjsbackend  refs/changes/56/27256/4   &&   git  cherry-pick  FETCH_HEAD

    如果有冲突的话就解决冲突的代码。

     

     

  • 编译qtbase

    现在我们已经准备好了为树莓派交叉编译Qt5所需要的全部资源,在正式编译之前只需要执行一个小脚本来修正一下符号链接和库文件路径设置:

    1diveinedu@debian:~/opt/qt5cd  ~/opt/cross-compile-tools
    2diveinedu@debian:~/opt/qt5sudo  ./fixQualifiedLibraryPaths /mnt/rasp-pi-rootfs/ ~/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc

    进入qt5/qtbase目录执行以下脚本进行配置和编译工作:

    1diveinedu@debian:~/opt/qt5$ cd ~/opt/qt5/qtbase
    2diveinedu@debian:~/opt/qt5/qtbase$ ./configure -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=~/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf- -sysroot /mnt/rasp-pi-rootfs -opensource -confirm-license -optimized-qmake -reduce-relocations -reduce-exports -release -make libs -prefix /usr/local/qt5pi -no-pch
    3diveinedu@debian:~/opt/qt5/qtbase$ make -j 4
    4diveinedu@debian:~/opt/qt5/qtbase$ sudo make install

     

  • 编译其他模块

    执行到这步的时候,你已经有了针对树莓派交叉编译的qmake工具了,你可以一一的去交叉编译Qt5的其他模块了,为里避免模块编译过程中可能 出现的依赖错误,建议按照这个模块顺序去编译: qtimageformats, qtsvg, qtjsbackend, qtscript, qtxmlpatterns, qtdeclarative, qtsensors, qt3d, qtgraphicaleffects,qtjsondb,qtlocation, qtdocgallery.

    模块编译相关的类似命令:

    1diveinedu@debian:~/opt/qt5$ cd qtimageformats
    2diveinedu@debian:~/opt/qt5/qtimageformats$ /usr/local/qt5pi/bin/qmake .
    3diveinedu@debian:~/opt/qt5/qtimageformats$ make -j4
    4diveinedu@debian:~/opt/qt5/qtimageformats$ sudo make install

    把你所需要或者所想编译的模块都按顺序执行编译安装命令后,所有需要的东西都安装在了镜像文件(raspbain wheezy image)里面了。我们接下来就是把他烧到SD卡上去。 SD卡烧写命令:

    1diveinedu@debian:~/opt/qt5$ cd ~/opt/
    2diveinedu@debian:~/opt$ sync; sudo umount /mnt/rasp-pi-rootfs
    3diveinedu@debian:~/opt$ sudo dd bs=1M if=2013-02-09-wheezy-raspbian.img of=/dev/sdc; sync

    提示:/dev/sdc是我使用的SD的设备, 请根据自己的实际情况修改。

感谢你能够认真阅读完这篇文章,希望小编分享的“树莓派如何实现Qt5交叉编译移植”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI