Create Qt on Raspberry Pi
[toc align_right="yes" depth="2"]
Qt on Raspberry Pi — Create
QtonPi App SDK
QtonPi Release-0.x App SDK consists of,
- Qt Creator
- Sysroot + Toolchain
As indicated in the roadmap, we hope to have a more integrated App SDK from Release-1.x onwards.
Download
QtonPi releases are distributed via BitTorrent. QtonPi download page is here.
Upon downloading a QtonPi release, you should see a tarball <code>qtonpi-X.Y.tar.bz2</code>, where <code>"X"</code> is the major release number and <code>"Y"</code> is the minor release.
QtonPi release directory is organized as follows,
<br />qtonpi-X.Y/<br />├── app-sdk/<br />├── platform-sdk/<br />│ ├── host-rpms/<br />│ ├── image-creator-binaries/<br />│ └── mt-cross-tools/<br />└── sdcard-img/<br />
Following is a brief description of the directory structure,
<code>app-sdk/</code> | Application SDK |
<code>platform-sdk/</code> | Platform SDK - In case you would like to roll your own SD Card Image and/or Sysroot. See [[Contribute |
<code>sdcard-img/</code> | Default SD Card Image - Please use this for reporting bugs! |
Install
Qt Creator
First step would be to install Qt Creator. You will find Qt Creator installer here,
<br />qtonpi-X.Y/<br />├── app-sdk/<br />│ └── qt-creator-linux-x86-opensource-2.x.y.bin<br />
To install, just run the <code>qt-creator-linux-x86-opensource-2.x.y.bin</code> file
<br />$ pwd<br />/home/rajiv/qtonpi-0.2/app-sdk<br />$ ./qt-creator-linux-x86-opensource-2.4.1.bin<br />
This should install, launch Qt Creator. In addition, it'll also create an icon on your Desktop.
Toolchain and Sysroot
Next step would be to install the toolchain and default sysroot. You can find it here,
<br />qtonpi-X.Y/<br />├── app-sdk/<br />│ └── toolchain-and-sysroot-armv5tel.tar.bz2<br />
You will need to extract this as <code>root</code> user, into the <code>root("/")</code> directory of your filesystem.
<br />$ cd /<br />$ pwd<br />/<br />$ sudo tar jxvf /home/rajiv/qtonpi-0.2/app-sdk/toolchain-and-sysroot-armv5tel.tar.bz2<br />
Qt 5
QtonPi ships with a known working (necessarily not stable!) version of Qt 5. This version works both on the sysroot and the target and you can find it here,
<br />qtonpi-0.2/<br />├── app-sdk/<br />│ ├── opt-qt5-current.tar.bz2<br />
You will need to extract this as <code>root</code> user, into the <code>root("/")</code> directory of your filesystem.
<br />$ cd /<br />$ pwd<br />/<br />$ sudo tar jxvf /home/rajiv/qtonpi-0.2/app-sdk/opt-qt5-current.tar.bz2<br />
SD Card Image
In addition, there is also a default 2GB SD Card Image, with Qt 5 on it. You'll find it here.
<br />qtonpi-X.Y/<br />└── sdcard-img/<br /> └── qtonpi-sdcard-X.Y.img.bz2<br />
To setup your SD card, <code>cat/dd</code> the contents of this file onto your SD Card. Assuming your SD Card device is <code>/dev/sdb</code>, one way to do this is as follows. Note you'll need to be logged in as <code>root</code> in order to be able to write to <code>/dev/sdb</code> device.
<br /># pwd<br />/home/rajiv/qtonpi-0.2/sdcard-img<br /># bzcat qtonpi-sdcard-0.2.img.bz2 > /dev/sdb; sync<br />
You're now ready to boot your Raspberry Pi Device! There are two accounts - <code>root</code> and <code>qtonpi</code>. Password for the accounts are <code>rootme</code> and <code>qtonpi</code> respectively.
Upon booting and logging into your Raspberry Pi device as <code>root</code>, you'll need to enable networking (which is disabled by default!). If you've DHCP setup, find out the ethernet interface of your Raspberry Pi device by doing <code>ifconfig -a</code> and run <code>dhclient eth0</code> on that interface.
<br />-bash-4.1# ifconfig -a<br />eth0 Link encap:Ethernet HWaddr B8:27:EB:E2:26:B5
[…]
-bash-4.1# dhclient eth0
[…]
-bash-4.1# ifconfig -a<br />eth0 Link encap:Ethernet HWaddr B8:27:EB:44:23:50<br /> inet addr:10.48.194.196 Bcast:10.48.194.255 Mask:255.255.255.128<br /> UP BROADCAST RUNNING MULTICAST MTU:1488 Metric:1<br /> RX packets:549 errors:0 dropped:0 overruns:0 frame:0<br /> TX packets:46 errors:0 dropped:0 overruns:0 carrier:0<br /> collisions:0 txqueuelen:1000<br /> RX bytes:90538 (88.4 KiB) TX bytes:8025 (7.8 KiB)<br />
<code>dhclient</code> usually does a lousy job at giving useful information. So, once you are back on the command prompt, do an <code>ifconfig -a</code> to see if an IP Address got assigned. In the above example, eth0 has an IP address of 10.48.194.196.
Then update the date/time on Raspberry Pi device. This can be done easily using <code>ntpdate</code>
<br />-bash-4.1# ntpdate -u 0.us.pool.ntp.org<br />
Configuring Qt Creator, Toolchain, Qt 5 and Raspberry Pi board
Connecting Qt Creator to Raspberry Pi board
By this time you should be able to ssh from your host machine (running Qt Creator) into your Raspberry Pi Board. If you are not able to do so, please check your network connectivity before proceeding any further!
- Launch Qt Creator and select Tools
> Options> Linux Devices - Click Add and select Generic Linux Device. Then Click on Start Wizard
- Enter the following in the dialog box that appears
- The name to identify this configuration: <code>Raspberry Pi</code>
- The device's hostname or IP address : IP Address of your Raspberry Pi device
- The user name to log into the device: <code>root</code>
- The authentication type: Select Password
- The user's password: <code>rootme</code>
- Click Next followed by Finish
- The Device Test should finish successfully. If not, go back and check your network connectivity and other settings.
Setting up your toolchain
- In Qt Creator, select Tools
> Options> Build & Run and Tool Chains tab - Select Manual and click on Add
- In the dropdown menu, select GCC
- Then select GCC, as it appears below Manual and specify the Compiler path: as /opt/qtonpi/bin/armv5tel-qtonpi-linux-gnueabi-gcc and Debugger: as /opt/qtonpi/bin/armv5tel-qtonpi-linux-gnueabi-gdb
- Click on Apply and select OK
Selecting Qt 5 for Raspberry Pi
- In Qt Creator, select Tools
> Options> Build & Run and Qt Versions tab - Select Manual and click on Add…
- Then select <code>qmake</code> file located in /opt/qt5/bin/qmake and click on Open
- Click on Apply and select OK
Qt creator might indicate "Qt version 5.0.0 for Desktop", which can be safely ignored for now.
Hello QtonPi!
QtonPi App SDK comes with <code>hello-qtonpi</code> App to get you started with Qt 5, which is located here,
<br />qtonpi-X.Y/<br />├── app-sdk/<br />│ ├── hello-qtonpi.tar.bz2<br />
Feel free to extract the tarball anywhere in your home directory.
<br />$ pwd<br />/home/rajiv<br />$ tar jxvf qtonpi-0.2/app-sdk/hello-qtonpi.tar.bz2<br />hello-qtonpi/<br />hello-qtonpi/main.cpp<br />hello-qtonpi/hello-qtonpi.pro<br />[…]<br />
Next launch Qt Creator (if you don't already have it running!), and do the following.
- Select File -> Open File or Project…, navigate to <code>hello-qtonpi/hello-qtonpi.pro</code> and click Open
- When you do this first time, Project Setup Dialog appears for the Target Setup, with sane defaults. Select Finish
- In the side-bar, select Projects mode or press Control-5, and go into Run Settings
- In the Deployment section, click on Add and select Deploy to Remote Linux Host
- In Device Configuration you should see Raspberry Pi (Default)
- In the Run section, click on Add and select hello-qtonpi (on Remote Generic Linux Host)
- At this point, you should be all set to roll. In the side-bar, select Edit mode or press Control-2
- To build your project, select Build -> Build All. This should build the binary using QtonPi toolchain.
- Next step would be deploy your binaries onto your Raspberry Pi Device. To do this, select Build -> Deploy All. Your Raspberry Pi device should now have <code>hello-qtonpi</code> executable in <code>/root/hello-qtonpi</code> directory.
- To run your newly minted App, select Build
> Run*, and at this point you should see your Qt 5 Qt Quick App running on your display
Qt Quick for C++ Developers":http://qt.nokia.com/learning/online/training/materials/qt-essentials-qt-quick-edition
Now that you've a working QtonPi SDK, next step would be to learn more about Qt Quick. Following are some resources to help you get started.
* "Qt Essentials
"Qt Quick for Designers":http://qt.nokia.com/learning/online/training/materials/qt-quick-for-designers
Uninstall
Release 0.x of QtonPi SDK consists of three parts, which you'll need to uninstall separately.
- Qt Creator
- Qt 5
- QtonPi Toolchain and Sysroot
Note - If you are updating between 0.x releases, you do not have to uninstall Qt Creator each time.
Qt Creator
In order to uninstall Qt Creator, go to the <code>bin/</code> directory in your Qt Creator installation and execute the <code>uninstall</code> command.
<br />$ pwd<br />/home/rajiv<br />$ cd qtcreator-2.4.1/bin<br />$ pwd<br />/home/rajiv/qtcreator-2.4.1/bin<br />$ ./uninstall<br />
Toolchain and Sysroot
Uninstalling the toolchain and sysroot is as simple as removing the <code>/opt/qtonpi/</code> directory.
<br />$ sudo rm -rf /opt/qtonpi/<br />
Should take care of it!
Qt 5
Likewise, to uninstall Qt 5, remove <code>/opt/qt5/</code> directory.
$ sudo rm -rf /opt/qt5/