Raspberrypi beginners guide: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Convert ExpressionEngine links)
(Redirect to RaspberryPi Beginners Guide)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}
#REDIRECT [[RaspberryPi Beginners Guide]]


h1. Beginner's guide to cross-compile Qt5 on RaspberryPi
= Beginner's guide to cross-compile Qt5 on RaspberryPi =
 
[toc align_right="yes" depth="2"]


== Introduction ==
== Introduction ==
Line 13: Line 11:
For help, run
For help, run


<code> $ ./bakeqtpi.bash —help<code>
<code>$ ./bakeqtpi.bash —help</code>


== Getting Started ==
== Getting Started ==


First we create a folder to hold the source code and all the required files to do the cross-compilation. We chose to create a directory named "opt" in the home folder:
First we create a folder to hold the source code and all the required files to do the cross-compilation. We chose to create a directory named "opt" in the home folder:
</code>paulo@westeros:~$ mkdir~/opt
<code>paulo@westeros:~$ mkdir~/opt
paulo@westeros:~$ cd~/opt<code>
paulo@westeros:~$ cd~/opt</code>


Now, download the following files:
Now, download the following files:
* Raspbian Wheezy image from ([http://www.raspberrypi.org/downloads here]):
* Raspbian Wheezy image from ([http://www.raspberrypi.org/downloads here]):
</code>paulo@westeros:~/opt$ wget http://downloads.raspberrypi.org/raspbian_latest/ -O wheezy-raspbian-latest.zip
<code>paulo@westeros:~/opt$ wget http://downloads.raspberrypi.org/raspbian_latest/ -O wheezy-raspbian-latest.zip
paulo@westeros:~/opt$ unzip wheezy-raspbian-latest.zip<code>
paulo@westeros:~/opt$ unzip wheezy-raspbian-latest.zip</code>
And mount it:
And mount it:
</code>paulo@westeros:~/opt$ sudo mkdir /mnt/rasp-pi-rootfs
<code>paulo@westeros:~/opt$ sudo mkdir /mnt/rasp-pi-rootfs
paulo@westeros:~/opt$ sudo mount -o loop,offset=62914560 2015-02-16-raspbian-wheezy.img /mnt/rasp-pi-rootfs<code>
paulo@westeros:~/opt$ sudo mount -o loop,offset=62914560 2015-02-16-raspbian-wheezy.img /mnt/rasp-pi-rootfs</code>


* The toolchain built by Donald: (Note, seems to be dead links!)
* The toolchain built by Donald: (Note, seems to be dead links!)
</code>paulo@westeros:~/opt$ wget https://www.dropbox.com/s/sl919ly0q79m1e6/gcc-4.7-linaro-rpi-gnueabihf.tbz
<code>paulo@westeros:~/opt$ wget https://www.dropbox.com/s/sl919ly0q79m1e6/gcc-4.7-linaro-rpi-gnueabihf.tbz
(or a mirror at http://swap.tsmt.eu/gcc-4.7-linaro-rpi-gnueabihf.tbz with sha1 f6255c6aca925239dc943d22a794f642daa17e65)
(or a mirror at http://swap.tsmt.eu/gcc-4.7-linaro-rpi-gnueabihf.tbz with sha1 f6255c6aca925239dc943d22a794f642daa17e65)
(or better at http://de.sourceforge.jp/projects/sfnet_rfidmonitor/downloads/crosscompilation-resources/gcc-4.7-linaro-rpi-gnueabihf.tbz
(or better at http://de.sourceforge.jp/projects/sfnet_rfidmonitor/downloads/crosscompilation-resources/gcc-4.7-linaro-rpi-gnueabihf.tbz
as the above noted links seem to be broken)
as the above noted links seem to be broken)
paulo@westeros:~/opt$ tar -xf gcc-4.7-linaro-rpi-gnueabihf.tbz<code>
paulo@westeros:~/opt$ tar -xf gcc-4.7-linaro-rpi-gnueabihf.tbz</code>
Pro tip: don't build your own cross-compiler. You'll overlook something important and loose a couple of hours of your life for nothing. A suitable Raspberry Pi cross-compiler is also available here: https://github.com/raspberrypi/tools
Pro tip: don't build your own cross-compiler. You'll overlook something important and loose a couple of hours of your life for nothing. A suitable Raspberry Pi cross-compiler is also available here: https://github.com/raspberrypi/tools


It is a 32-bit build so if you are running on a 64-bit machine (you probably are) you need to install ia32-libs:
It is a 32-bit build so if you are running on a 64-bit machine (you probably are) you need to install ia32-libs:
</code>paulo@westeros:~/opt$ sudo apt-get install ia32-libs</code>
<code>paulo@westeros:~/opt$ sudo apt-get install ia32-libs</code>


* Clone the cross-compile-tools repository:
* Clone the cross-compile-tools repository:
<code>paulo@westeros:~/opt$ git clone git://gitorious.org/cross-compile-tools/cross-compile-tools.git<code>
<code>paulo@westeros:~/opt$ git clone git://gitorious.org/cross-compile-tools/cross-compile-tools.git</code>


* Clone and init the Qt5 repository:
* Clone and init the Qt5 repository:
</code>paulo@westeros:~/opt$ git clone git://gitorious.org/qt/qt5.git
<code>paulo@westeros:~/opt$ git clone git://gitorious.org/qt/qt5.git
paulo@westeros:~/opt$ cd qt5
paulo@westeros:~/opt$ cd qt5
paulo@westeros:~/opt/qt5$ ./init-repository<code>
paulo@westeros:~/opt/qt5$ ./init-repository</code>
If you're behind a firewall ./init-repository might fail. First run this command:
If you're behind a firewall ./init-repository might fail. First run this command:
</code>paulo@westeros:~/opt/qt5$ sed -i 's/git:/https:git./' .gitmodules</code>
<code>paulo@westeros:~/opt/qt5$ sed -i 's/git:/https:git./' .gitmodules</code>
Then retry:
Then retry:
<code>paulo@westeros:~/opt/qt5$ ./init-repository -f<code>
<code>paulo@westeros:~/opt/qt5$ ./init-repository -f</code>
 
* Finally, apply a patch on the qtjsbackend repository:
</code>paulo@wseteros:~/opt/qt5$ cd ~/opt/qt5/qtjsbackend
paulo@wseteros:~/opt/qt5/qtjsbackend$ git fetch https://codereview.qt.io/p/qt/qtjsbackend refs/changes/56/27256/4 &amp;&amp; git cherry-pick FETCH_HEAD<code>


h2. Compiling qtbase
* Finally, apply a patch on the qtjsbackend repository (Nb: You shouldn't need to patch with the latest verson of the Qt5 repo):
<code>paulo@wseteros:~/opt/qt5$ cd ~/opt/qt5/qtjsbackend
paulo@wseteros:~/opt/qt5/qtjsbackend$ git fetch https://codereview.qt.io/p/qt/qtjsbackend refs/changes/56/27256/4 && git cherry-pick FETCH_HEAD</code>


== Compiling qtbase ==
Now the we have all the resources needed to compile qt5 for raspberry, we need to execute a script to fix symlinks and lib paths:
Now the we have all the resources needed to compile qt5 for raspberry, we need to execute a script to fix symlinks and lib paths:


</code>paulo@westeros:~$ cd~/opt/cross-compile-tools
<code>paulo@westeros:~$ cd~/opt/cross-compile-tools
paulo@westeros:~$ sudo ./fixQualifiedLibraryPaths /mnt/rasp-pi-rootfs/~/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc<code>
paulo@westeros:~$ sudo ./fixQualifiedLibraryPaths /mnt/rasp-pi-rootfs/ ~/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc</code>


Go to the qt5/qtbase folder and run:
Go to the qt5/qtbase folder and run:
</code>paulo@westeros:~/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-exports -release -make libs -prefix /usr/local/qt5pi
<code>paulo@westeros:~/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-exports -release -make libs -prefix /usr/local/qt5pi
paulo@westeros:~/opt/qt5/qtbase$ make -j 4
paulo@westeros:~/opt/qt5/qtbase$ make -j 4
paulo@westeros:~/opt/qt5/qtbase$ sudo make install<code>
paulo@westeros:~/opt/qt5/qtbase$ sudo make install</code>
Note: if you want the qmlscene binary you should add -make tools to the ./configure command.
Note: if you want the qmlscene binary you should add -make tools to the ./configure command.


Line 75: Line 72:


To compile, you must do like the example below:
To compile, you must do like the example below:
</code>paulo@westeros:~/opt/qt5$ cd qtimageformats
<code>paulo@westeros:~/opt/qt5$ cd qtimageformats
paulo@westeros:~/opt/qt5/qtimageformats$ /usr/local/qt5pi/bin/qmake .
paulo@westeros:~/opt/qt5/qtimageformats$ /usr/local/qt5pi/bin/qmake .
paulo@westeros:~/opt/qt5/qtimageformats$ make -j4
paulo@westeros:~/opt/qt5/qtimageformats$ make -j4
paulo@westeros:~/opt/qt5/qtimageformats$ sudo make install<code>
paulo@westeros:~/opt/qt5/qtimageformats$ sudo make install</code>


We have all the modules installed in the wheezy image, now we can copy it to the sdcard using dd:
We have all the modules installed in the wheezy image, now we can copy it to the sdcard using dd:
</code>paulo@westeros:~/opt/qt5$ cd~/opt/
<code>paulo@westeros:~/opt/qt5$ cd~/opt/
paulo@westeros:~/opt$ sync; sudo umount /mnt/rasp-pi-rootfs
paulo@westeros:~/opt$ sync; sudo umount /mnt/rasp-pi-rootfs
paulo@westeros:~/opt$ sudo dd bs=1M if=2012-07-15-wheezy-raspbian.img of=/dev/sdb; sync
paulo@westeros:~/opt$ sudo dd bs=1M if=2015-02-16-raspbian-wheezy.img of=/dev/sdb; sync
<code>
</code>


obs: Check the entry point of your sdcard. Mine was /dev/sdb.
obs: Check the entry point of your sdcard. Mine was /dev/sdb.
Line 91: Line 88:


* Because your sdcard will be partitioned, OSX won't let you umount it, so you'll need to type:
* Because your sdcard will be partitioned, OSX won't let you umount it, so you'll need to type:
</code>sudo diskutil umountDisk /dev/disk3</code>
<code>sudo diskutil umountDisk /dev/disk3</code>


where "disk3" will be the /dev/diskXsY where your sdcard first appeared.
where "disk3" will be the /dev/diskXsY where your sdcard first appeared.


* To perform dd you will need to use the *r*disk index, so if your sdcard is disk3 you will need to type:
* To perform dd you will need to use the *r*disk index, so if your sdcard is disk3 you will need to type:
<code>sudo dd bs=1M if=2012-07-15-wheezy-raspbian.img of=/dev/rdisk3; sync<code>
<code>sudo dd bs=1M if=2015-02-16-wheezy-raspbian.img of=/dev/rdisk3; sync</code>


Boot up your pi.
Boot up your pi.
Line 106: Line 103:
=== Tool Chain Settings ===
=== Tool Chain Settings ===


go to '''Tools -> Options..-> Build &amp; Run -> Compilers''' tab.
go to '''Tools -> Options..-> Build & Run -> Compilers''' tab.
click in "'''Add -> GCC'''".
click in "'''Add -> GCC'''".
On "'''Compiler Path'''" set to "/home/<you>/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-g+''".
On "'''Compiler Path'''" set to "/home/<you>/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-g+''".
Line 112: Line 109:
obs: Adjust it to your username.
obs: Adjust it to your username.


h3. Qt Version settings.
=== Qt Version settings. ===
 
Now go to '''Tools -> Options..-> Build & Run -> Qt Versions''' tab.
Now go to '''Tools -> Options..-> Build &amp; Run -> Qt Versions''' tab.
Click in "Add.." and choose you qmake for raspberry "/usr/local/qt5pi/bin/qmake".
Click in "Add.." and choose you qmake for raspberry "/usr/local/qt5pi/bin/qmake".


'''Note for OSX'''
'''Note for OSX'''
* Because /usr is not visible by default, you first need to open a terminal and type:
* Because /usr is not visible by default, you first need to open a terminal and type:
</code>sudo SetFile -a v /usr</code>
<code>sudo SetFile -a v /usr</code>
* After you've completed the qmake selection, if you wish to make /usr invisible again, type the same command with a capital V :
* After you've completed the qmake selection, if you wish to make /usr invisible again, type the same command with a capital V :
<code>sudo SetFile -a V /usr<code>
<code>sudo SetFile -a V /usr</code>
 
h3. Configure Linux Devices


=== Configure Linux Devices ===
Go to '''Tools -> Options…-> Devices -> Devices''' tab.
Go to '''Tools -> Options…-> Devices -> Devices''' tab.


Line 135: Line 130:
Now you are ready to run your first Qt raspberry pi project.
Now you are ready to run your first Qt raspberry pi project.


h2. Example Project
== Example Project ==
 
You can download a hello world project:
You can download a hello world project:
</code>paulo@westeros:~$ git clone https://git.gitorious.org/qt5-raspberrypi-example/qt5-raspberrypi-example.git</code>
<code>paulo@westeros:~$ git clone https://git.gitorious.org/qt5-raspberrypi-example/qt5-raspberrypi-example.git</code>


Open the project in Qt Creator and go to the Projects pane.
Open the project in Qt Creator and go to the Projects pane.
Line 155: Line 149:
Now you can build and run your application from Qt Creator.
Now you can build and run your application from Qt Creator.


h2. Troubleshooting
== Troubleshooting ==
 
=== Qt version not properly installed ===
h3. Qt version not properly installed
 
You need to keep the SD card image mounted during development!
You need to keep the SD card image mounted during development!


If QtCreator still reports this after mounting the SD card image, then you may need to create the directories missing from  
If QtCreator still reports this after mounting the SD card image, then you may need to create the directories missing from  


<code>/mnt/rasp-pi-rootfs/usr/local/qt5pi/<code>
<code>/mnt/rasp-pi-rootfs/usr/local/qt5pi/</code>


or whatever the mount path is (these will probably include bin, translations, and so on). You can create empty directories using the mkdir command.
or whatever the mount path is (these will probably include bin, translations, and so on). You can create empty directories using the mkdir command.


h3. The default mkspec symlink is broken.
=== The default mkspec symlink is broken. ===
 
It means that mkspec is not found on your sysroot, so your must copy it.
It means that mkspec is not found on your sysroot, so your must copy it.


</code>paulo@westeros:~$ sudo cp -r /usr/local/qt5pi/mkspecs/ /mnt/rasp-pi-rootfs/usr/local/qt5pi/</code>
<code>paulo@westeros:~$ sudo cp -r /usr/local/qt5pi/mkspecs/ /mnt/rasp-pi-rootfs/usr/local/qt5pi/</code>


If the problem persists, create the missing symlink, e.g.
If the problem persists, create the missing symlink, e.g.


<code>sudo ln -s /usr/local/qt5pi/mkspecs/devices/linux-rasp-pi-g''+ /usr/local/qt5pi/mkspecs/default<code>
<code>sudo ln -s /usr/local/qt5pi/mkspecs/devices/linux-rasp-pi-g''+ /usr/local/qt5pi/mkspecs/default</code>


It is probably a good idea to do the same for the sysroot mkspecs.
It is probably a good idea to do the same for the sysroot mkspecs.
Line 183: Line 174:
It seems Qt's include was not found and you must add it to you .pro file:
It seems Qt's include was not found and you must add it to you .pro file:


</code>INCLUDEPATH ''= /mnt/rasp-pi-rootfs/usr/local/qt5pi/include/</code>
<code>INCLUDEPATH ''= /mnt/rasp-pi-rootfs/usr/local/qt5pi/include/</code>
 
h3. cc1: fatal error: .pch/release-shared/QtGui: No such file or directory


=== cc1: fatal error: .pch/release-shared/QtGui: No such file or directory ===
Some people have seen this error. Adding the "-no-pch" option when running configure should prevent it.
Some people have seen this error. Adding the "-no-pch" option when running configure should prevent it.


h3. Getting Could not determine the target architecture! and Could not determine the host architecture!
=== Getting Could not determine the target architecture! and Could not determine the host architecture! ===
 
If you are getting this kind of error, it is possible that your current git branch is something other than master. To be sure, do the following:
If you are getting this kind of error, it is possible that your current git branch is something other than master. To be sure, do the following:


<code>daniel@daniel-t3500 : ~/opt/qt5/qtbase $ git branch <code>
<code>daniel@daniel-t3500 : ~/opt/qt5/qtbase $ git branch </code>


If it shows like this:
If it shows like this:
</code>* (no branch)
<code>* (no branch)
  master<code>
  master</code>


Then you must checkout to master branch before running ./configure:
Then you must checkout to master branch before running ./configure:
</code>daniel@daniel-t3500 :~/opt/qt5/qtbase $ git checkout master
<code>daniel@daniel-t3500 :~/opt/qt5/qtbase $ git checkout master
daniel@daniel-t3500 : ~/opt/qt5/qtbase $ git branch
daniel@daniel-t3500 : ~/opt/qt5/qtbase $ git branch
* master<code>
* master</code>


It is also good to fetch the latest commits and apply them by doing:
It is also good to fetch the latest commits and apply them by doing:
</code>daniel@daniel-t3500 :~/opt/qt5/qtbase $ git pull</code>
<code>daniel@daniel-t3500 :~/opt/qt5/qtbase $ git pull</code>


Also, check for the installation of libz (32 bits) in yor system. In ubuntu (64 bits) you might just:
Also, check for the installation of libz (32 bits) in yor system. In ubuntu (64 bits) you might just:
<code>sudo apt-get install lib32z1-dev<code>
<code>sudo apt-get install lib32z1-dev</code>


After the ./configure script has failed first run these commands before restarting ./configure:
After the ./configure script has failed first run these commands before restarting ./configure:


</code>daniel@daniel-t3500 : ~/opt/qt5/qtbase $ git reset —hard
<code>daniel@daniel-t3500 : ~/opt/qt5/qtbase $ git reset —hard
daniel@daniel-t3500 :~/opt/qt5/qtbase $ git git clean -dxf<code>
daniel@daniel-t3500 :~/opt/qt5/qtbase $ git git clean -dxf</code>
 
h3. EGL Error : Could not create the egl surface: error = 0x3000


=== EGL Error : Could not create the egl surface: error = 0x3000 ===
Try allocating more memory to video (try 64 or 128MB). Use the raspi-config utility to change this.
Try allocating more memory to video (try 64 or 128MB). Use the raspi-config utility to change this.


</code>pi@raspberrypi ~ $ sudo raspi-config</code>
<code>pi@raspberrypi ~ $ sudo raspi-config</code>
 
h3. ABI detection failed


=== ABI detection failed ===
You will need Qt Creator 2.6 for Qt5 up to and including beta2.
You will need Qt Creator 2.6 for Qt5 up to and including beta2.
Any Qt 5 later than that will need to use nightly snapshots (or will have to wait for Qt Creator 2.6.1): After the beta2 all libraries were renamed again.
Any Qt 5 later than that will need to use nightly snapshots (or will have to wait for Qt Creator 2.6.1): After the beta2 all libraries were renamed again.
Line 228: Line 215:
See [http://forum.qt.io/viewthread/22023 this forum thread for more details]
See [http://forum.qt.io/viewthread/22023 this forum thread for more details]


h3. ./configure: 2654: ./configure: /home/<you>/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-g: not found -reduce-exports was requested but this compiler does not support it
=== ./configure: 2654: ./configure: /home/<you>/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-g: not found -reduce-exports was requested but this compiler does not support it ===
 
The error message is totally misleading. The real cause is that the precompile toolchain is 32-bit, so you need to:
The error message is totally misleading. The real cause is that the precompile toolchain is 32-bit, so you need to:
<code>sudo apt-get install ia32-libs<code>
<code>sudo apt-get install ia32-libs</code>
 
h3. make: g: Command not found


=== make: g: Command not found ===
Qt requires a native (non-cross-compiling) copy of g''+ to be installed in order to build qmake. You can't use clang. Fix with:
Qt requires a native (non-cross-compiling) copy of g''+ to be installed in order to build qmake. You can't use clang. Fix with:
</code>sudo apt-get install g++</code>
<code>sudo apt-get install g++</code>


=== /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libdl.a(dlopen.o): In function `dlopen': (.text+0xc): undefined reference to `__dlopen' ===
=== /mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libdl.a(dlopen.o): In function `dlopen': (.text+0xc): undefined reference to `__dlopen' ===

Latest revision as of 08:28, 9 April 2015

Beginner's guide to cross-compile Qt5 on RaspberryPi

Introduction

This is a step by step guide to help beginners to: cross-compile QT5 for RaspberryPi(wheezy), create, deploy and run an example project. This article will focus on simplicity, so if you are looking for additional customization, please check a more detailed guide.

For an easy install, try this script. Or get a later version here For help, run

$ ./bakeqtpi.bash help

Getting Started

First we create a folder to hold the source code and all the required files to do the cross-compilation. We chose to create a directory named "opt" in the home folder:

paulo@westeros:~$ mkdir~/opt
paulo@westeros:~$ cd~/opt

Now, download the following files:

  • Raspbian Wheezy image from (here):
paulo@westeros:~/opt$ wget http://downloads.raspberrypi.org/raspbian_latest/ -O wheezy-raspbian-latest.zip
paulo@westeros:~/opt$ unzip wheezy-raspbian-latest.zip

And mount it:

paulo@westeros:~/opt$ sudo mkdir /mnt/rasp-pi-rootfs
paulo@westeros:~/opt$ sudo mount -o loop,offset=62914560 2015-02-16-raspbian-wheezy.img /mnt/rasp-pi-rootfs
  • The toolchain built by Donald: (Note, seems to be dead links!)
paulo@westeros:~/opt$ wget https://www.dropbox.com/s/sl919ly0q79m1e6/gcc-4.7-linaro-rpi-gnueabihf.tbz
(or a mirror at http://swap.tsmt.eu/gcc-4.7-linaro-rpi-gnueabihf.tbz with sha1 f6255c6aca925239dc943d22a794f642daa17e65)
(or better at http://de.sourceforge.jp/projects/sfnet_rfidmonitor/downloads/crosscompilation-resources/gcc-4.7-linaro-rpi-gnueabihf.tbz
as the above noted links seem to be broken)
paulo@westeros:~/opt$ tar -xf gcc-4.7-linaro-rpi-gnueabihf.tbz

Pro tip: don't build your own cross-compiler. You'll overlook something important and loose a couple of hours of your life for nothing. A suitable Raspberry Pi cross-compiler is also available here: https://github.com/raspberrypi/tools

It is a 32-bit build so if you are running on a 64-bit machine (you probably are) you need to install ia32-libs:

paulo@westeros:~/opt$ sudo apt-get install ia32-libs
  • Clone the cross-compile-tools repository:
paulo@westeros:~/opt$ git clone git://gitorious.org/cross-compile-tools/cross-compile-tools.git
  • Clone and init the Qt5 repository:
paulo@westeros:~/opt$ git clone git://gitorious.org/qt/qt5.git
paulo@westeros:~/opt$ cd qt5
paulo@westeros:~/opt/qt5$ ./init-repository

If you're behind a firewall ./init-repository might fail. First run this command:

paulo@westeros:~/opt/qt5$ sed -i 's/git:/https:git./' .gitmodules

Then retry:

paulo@westeros:~/opt/qt5$ ./init-repository -f
  • Finally, apply a patch on the qtjsbackend repository (Nb: You shouldn't need to patch with the latest verson of the Qt5 repo):
paulo@wseteros:~/opt/qt5$ cd ~/opt/qt5/qtjsbackend
paulo@wseteros:~/opt/qt5/qtjsbackend$ git fetch https://codereview.qt.io/p/qt/qtjsbackend refs/changes/56/27256/4 && git cherry-pick FETCH_HEAD

Compiling qtbase

Now the we have all the resources needed to compile qt5 for raspberry, we need to execute a script to fix symlinks and lib paths:

paulo@westeros:~$ cd~/opt/cross-compile-tools
paulo@westeros:~$ sudo ./fixQualifiedLibraryPaths /mnt/rasp-pi-rootfs/ ~/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gcc

Go to the qt5/qtbase folder and run:

paulo@westeros:~/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-exports -release -make libs -prefix /usr/local/qt5pi
paulo@westeros:~/opt/qt5/qtbase$ make -j 4
paulo@westeros:~/opt/qt5/qtbase$ sudo make install

Note: if you want the qmlscene binary you should add -make tools to the ./configure command.

Compiling other modules

Now that you have qmake, you can cross-compile the other modules. To avoid dependencies errors, the following order is sugested: qtimageformats, qtsvg, qtjsbackend, qtscript, qtxmlpatterns, qtdeclarative, qtsensors, qt3d, qtgraphicaleffects, qtjsondb, qtlocation, qtdocgallery.

To compile, you must do like the example below:

paulo@westeros:~/opt/qt5$ cd qtimageformats
paulo@westeros:~/opt/qt5/qtimageformats$ /usr/local/qt5pi/bin/qmake .
paulo@westeros:~/opt/qt5/qtimageformats$ make -j4
paulo@westeros:~/opt/qt5/qtimageformats$ sudo make install

We have all the modules installed in the wheezy image, now we can copy it to the sdcard using dd:

paulo@westeros:~/opt/qt5$ cd~/opt/
paulo@westeros:~/opt$ sync; sudo umount /mnt/rasp-pi-rootfs
paulo@westeros:~/opt$ sudo dd bs=1M if=2015-02-16-raspbian-wheezy.img of=/dev/sdb; sync

obs: Check the entry point of your sdcard. Mine was /dev/sdb.

Notes for OSX

  • Because your sdcard will be partitioned, OSX won't let you umount it, so you'll need to type:
sudo diskutil umountDisk /dev/disk3

where "disk3" will be the /dev/diskXsY where your sdcard first appeared.

  • To perform dd you will need to use the *r*disk index, so if your sdcard is disk3 you will need to type:
sudo dd bs=1M if=2015-02-16-wheezy-raspbian.img of=/dev/rdisk3; sync

Boot up your pi.

Configuring Qt Creator

To use Qt Creator properly, you must configure the "Qt Version" and "Tool Chains" sections.

Tool Chain Settings

go to Tools -> Options..-> Build & Run -> Compilers tab. click in "Add -> GCC". On "Compiler Path" set to "/home/<you>/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-g+". Name it "ARM GCC" or similar. obs: Adjust it to your username.

Qt Version settings.

Now go to Tools -> Options..-> Build & Run -> Qt Versions tab. Click in "Add.." and choose you qmake for raspberry "/usr/local/qt5pi/bin/qmake".

Note for OSX

  • Because /usr is not visible by default, you first need to open a terminal and type:
sudo SetFile -a v /usr
  • After you've completed the qmake selection, if you wish to make /usr invisible again, type the same command with a capital V :
sudo SetFile -a V /usr

Configure Linux Devices

Go to Tools -> Options…-> Devices -> Devices tab.

Add a new configuration setting a "Generic Linux Device" Hostname or IP address is the IP of your raspberry user is pi password is raspberry obs: if your not did change it.

Now you are ready to run your first Qt raspberry pi project.

Example Project

You can download a hello world project:

paulo@westeros:~$ git clone https://git.gitorious.org/qt5-raspberrypi-example/qt5-raspberrypi-example.git

Open the project in Qt Creator and go to the Projects pane. Click Manage Kits and then Add. Fill in: Name: Raspberry Pi Device Type: Generic Linux Device Device: Raspberry Pi Compiler: ARM GCC Debugger->Manage->Edit->"/home/<you>/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-gdb" (change your username) Qt version: Qt 5.x.x (qt5pi) Ok->Add Kit->Raspberry Pi

Then go to the "Rasperry Pi" kit tab->System Environment and add LD_LIBRARY_PATH which is set to /usr/local/qt5pi/lib

Now you can build and run your application from Qt Creator.

Troubleshooting

Qt version not properly installed

You need to keep the SD card image mounted during development!

If QtCreator still reports this after mounting the SD card image, then you may need to create the directories missing from

/mnt/rasp-pi-rootfs/usr/local/qt5pi/

or whatever the mount path is (these will probably include bin, translations, and so on). You can create empty directories using the mkdir command.

The default mkspec symlink is broken.

It means that mkspec is not found on your sysroot, so your must copy it.

paulo@westeros:~$ sudo cp -r /usr/local/qt5pi/mkspecs/ /mnt/rasp-pi-rootfs/usr/local/qt5pi/

If the problem persists, create the missing symlink, e.g.

sudo ln -s /usr/local/qt5pi/mkspecs/devices/linux-rasp-pi-g''+ /usr/local/qt5pi/mkspecs/default

It is probably a good idea to do the same for the sysroot mkspecs.

Include <QtGui/QtGui>: No such file or directory

It seems Qt's include was not found and you must add it to you .pro file:

INCLUDEPATH ''= /mnt/rasp-pi-rootfs/usr/local/qt5pi/include/

cc1: fatal error: .pch/release-shared/QtGui: No such file or directory

Some people have seen this error. Adding the "-no-pch" option when running configure should prevent it.

Getting Could not determine the target architecture! and Could not determine the host architecture!

If you are getting this kind of error, it is possible that your current git branch is something other than master. To be sure, do the following:

daniel@daniel-t3500 : ~/opt/qt5/qtbase $ git branch

If it shows like this:

* (no branch)
 master

Then you must checkout to master branch before running ./configure:

daniel@daniel-t3500 :~/opt/qt5/qtbase $ git checkout master
daniel@daniel-t3500 : ~/opt/qt5/qtbase $ git branch
* master

It is also good to fetch the latest commits and apply them by doing:

daniel@daniel-t3500 :~/opt/qt5/qtbase $ git pull

Also, check for the installation of libz (32 bits) in yor system. In ubuntu (64 bits) you might just:

sudo apt-get install lib32z1-dev

After the ./configure script has failed first run these commands before restarting ./configure:

daniel@daniel-t3500 : ~/opt/qt5/qtbase $ git reset hard
daniel@daniel-t3500 :~/opt/qt5/qtbase $ git git clean -dxf

EGL Error : Could not create the egl surface: error = 0x3000

Try allocating more memory to video (try 64 or 128MB). Use the raspi-config utility to change this.

pi@raspberrypi ~ $ sudo raspi-config

ABI detection failed

You will need Qt Creator 2.6 for Qt5 up to and including beta2. Any Qt 5 later than that will need to use nightly snapshots (or will have to wait for Qt Creator 2.6.1): After the beta2 all libraries were renamed again.

See this forum thread for more details

./configure: 2654: ./configure: /home/<you>/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-g: not found -reduce-exports was requested but this compiler does not support it

The error message is totally misleading. The real cause is that the precompile toolchain is 32-bit, so you need to:

sudo apt-get install ia32-libs

make: g: Command not found

Qt requires a native (non-cross-compiling) copy of g+ to be installed in order to build qmake. You can't use clang. Fix with:

sudo apt-get install g++

/mnt/rasp-pi-rootfs/usr/lib/arm-linux-gnueabihf/libdl.a(dlopen.o): In function `dlopen': (.text+0xc): undefined reference to `__dlopen'

You need to run the ./fixQualifiedLibraryPaths again.

See: http://stackoverflow.com/questions/13626726/an-error-building-qt-libraries-for-the-raspberry-pi for more info.

cc1: fatal error: .pch/release-shared/Qt5Gui: No such file or directory

Try adding -no-pch to the ./configure command line.

Cannot create forwarding script Betrete 'qtactiveqt'.git/hooks/commit-msg: Datei oder Verzeichnis nicht gefunden

Try:

unset LANG
./init-repository -f