Build a Qt cross-compiling environment for Raspberry Pi 2B and Raspberry Pi 3

Source: Internet
Author: User

Build a Qt cross-compiling environment for Raspberry Pi 2B and Raspberry Pi 3

The lab project needs to use Qt to develop a user interaction interface on Raspberry Pi. Although Raspberry Pi's hardware configuration is constantly improved with version updates, it still cannot meet the requirement of Qt development directly on Raspberry Pi. The first thing to do is to build a cross-compilation environment.

Follow these steps:

Experimental Platform: Raspberry Pi 2B (later I conducted an experiment on Raspberry Pi 3. Except for the different raspbian image files, other files remain unchanged, which proves the feasibility of this solution .)

1. Prepare the file (added after the download method)

2015-05-05-raspbian-wheezy.zip

Cross-compile-tools-master.zip

Gcc-4.7-linaro-rpi-gnueabihf.tbz

Qt-everywhere-opensource-src-5.4.1.tar

Qt-opensource-linux-x86-5.4.1.run

If you do not need to update the version, we recommend that you download the required files in strict accordance with the above version. Otherwise, problems may occur.

Baidu Network Disk download: http://pan.baidu.com/s/1gflswjp extraction password: 1em5

-------------------------------------- Split line --------------------------------------

Raspberry Pi tutorial illustration PDF

How to run Ubuntu Snappy Core in Raspberry Pi 2

Install NodeJS on the (Raspberry Pi) Raspberry Pi

Install Weston on Raspberry Pi

Linux OS for Raspberry Pi is available

Raspberry Pi (Raspberry Pi) trial note

Introduction to Raspberry Pi (Raspberry Pi) installation, IP configuration, and software source

-------------------------------------- Split line --------------------------------------

2. Build the environment

Ubuntu virtual machine created under VMware Workstation 12 Pro, with a 32-bit version of 12.04LTS. (I tried to install the 32-bit library in a 64-bit system, but it didn't run properly. Therefore, we recommend using the 32-bit Ubuntu)

 

 

3. Create a new folder named opt under the main folder of the Ubuntu system, put the prepared files into the opt folder, and decompress it.

4. Mount Raspberry Pi Images

$ Sudo mkdir/mnt/rasp-pi-rootfs

$ Sudo mount-o loop, offset = 62914560 raspbian-wheezy.img/mnt/rasp-pi-rootfs

Note:

(1) No space is allowed between loop and offset.

(2) What is the offset value equal? You can run the following command to view

$ Sudo fdisk-l 2015-05-05-raspbian-wheezy.img

Execution result:

Device Boot Start End Blocks Id

System

8192 raspbian-wheezy.img1 122879 57344 c

W95 FAT32 (LBA)

122880 raspbian-wheezy.img2 6399999 3138560 83 Linux

 

Offset = (512*122880.

5. Compile qtbase

$ Sudo apt-get install g ++

$ Cd ~ /Opt/cross-compile-tools

$ Sudo./fixQualifiedLibraryPaths/mnt/rasp-pi-rootfs /~ /Opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc

$ Cd ~ /Opt/qt-everywhere-opensource-src-5.4.1/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-release-reduce-exports- make libs-no-pch-make tools-prefix/usr/local/qt5pi-hostprefix/usr/local/qt5pi

(Execution time is relatively long) the execution result of this step:

$ Make-j 4

$ Sudo make install

$ For MODULE in qtimageformats qtsvg qtscript qtxmlpatterns qtdeclarative qtsensors qtgraphicaleffects qtlocation qtserialport qttools qtquick1 qtquickcontrols; do cd $ MODULE;/usr/local/qt5pi/bin/qmake .; make-j4; sudo make install; cd ..; done

(The execution of the preceding three commands takes a long time. Please wait. After execution)

6. Qt cross-compilation is successful, and a new Raspberry Pi image is burned.

First, insert the TF card of Raspberry Pi into the computer through the card reader.

$ Cd ~ /Opt/

$ Sync

$ Sudo umount/mnt/rasp-pi-rootfs

You can run the $ sudo fdisk-l command to view the mounting of the TF card in the Ubuntu system.

The blogger uses a 16 gb tf card and the Mount address is/dev/sdb. Therefore, run the following command:

$ Sudo dd bs = 4 M if = 2015-05-05-raspbian-wheezy.img of =/dev/sdb

After running the burn-write command, the terminal window does not display the burn-write process in detail, so you just need to wait for it.

After the data is written, the following information is displayed:

Note: At this time, mount the unmounted Raspberry Pi image to the original address again (because the files in this image need to be used as the library for cross-Compilation of Qt Creator. Otherwise, "Qt is not correctly installed, please run the install error" error during compilation). The mounting command is the same as before.

$ Sudo mount-o loop, offset = 62914560 raspbian-wheezy.img/mnt/rasp-pi-rootfs

Finally, insert the burned TF card into the Raspberry Pi and enable the Raspberry Pi.

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.