Overview
With Qt 5.2 working on the BeagleBone Black, created in Part 1 and Part 2, now it is time to compile a "Hello World" application. Assumptions:
- You are using an Ubuntu x64 host for creating Qt applications
- You have a Linaro toolchain located under /usr/local/linaro
- You have a BeagleBone connect to your host PC via a LAN
Downloads
No need to compile our own Qt Creator, just download it:- Qt Creator 3.0.0 Installer: Direct Link, Others
Video Tutorials
Derek Molloy has three excellent videos about Qt on the BeagleBone. I suggest you start with these, as it will make following these instructions easier.
- Part 1: BeagleBone LCDs and Qt
- Part 2: Using Qt Creator
- Part 3: A fully featured application
Setup Toolchain Environment
Open Qt Creator
Go to Tools -> Options
Add a new Device
Click on "Devices" from the list on the left
Click the "Add..." button on the upper right
Select Generic Linux Device
Click "Start Wizard" button
Enter "BBB - Ubuntu" for the name
Enter IP, and user information.
Click "Next" button
Click "Finish" button
Verify that the test connection was successful
Add a new Compiler
Click on the "Build & Run" item from the list on the left
Click on the "Compilers" tab
Click the "Add" drop down list button and select GCC
Change the name to "Linaro GCC"
Click the "Browse..." button next to the "Compiler path" field
Enter "/usr/local/linaro/bin/" into the filename field and click "Open"
Select "arm-linux-gnueabihf-g++" and click "Open" again
Click the "Apply" button
Add a new Debugger
Click on the "Debuggers" tab
Click the "Add" button
Enter "Linaro GDB" for the name
Click the "Browse..." button next to the Path field
Select "arm-linux-gnueabihf-gdb" and click "Open"
Click the "Apply" button
Add a new Qt Version
Click on the "Qt Versions" tab
Click the "Add..." button
Navigate to "/usr/local/qt-5.2/bin/qmake"
Click the "Open" button
Click the "Apply" button
Add a new Kit
Click on the "Kits" tab
Click the "Add" button
Change name to "BBB Kit"
Ensure that the device type is "Generic Linux Device"
Ensure that the device is "BBB - Ubuntu"
Select the "Linaro GCC" compiler from the Compiler drop down list button
Select the "Linaro GDB" debugger from the Debugger drop down list button
Select the "Qt 5.2.0 (qt-5.2)" version from the "Qt Version" drop down list button
Click the "Ok" button
Create a New Console Project
Under the Welcome page, Click the "New Project" button
Select "Applications" from the list on the left
Select "Qt Console Application"
Click the "Next" button
Enter "HelloWorld" in the name field
Change the target directory, if you like
Click on the "Next" button
Review the details and then click on the "Next" button
Click on the "Finish" button
Modify Auto-Generated Project
Edit main.cpp to look like this:
#include <QCoreApplication> #include <iostream> using namespace std; int main(int argc, char *argv[]) {QCoreApplication a(argc, argv);cout << "Hello World!" << endl;return a.exec();
}
This will build locally, but we want it to auto deploy to the BeagleBone. That's coming up next...
Create Deploy Configuration
Add the following three lines to HelloWorld.pro after the "TARGET=HelloWorld" linetarget.files = HelloWorld target.path = /home/ubuntu INSTALLS += target
That's it, now Qt Creator will automatically deploy the files before a debug or run.
Install GDB Server
This is required in order to debug from Qt Creator running on our host PC. This only needs to be done once. Issue this command on the Beaglebone:> sudo apt-get install gdbserver
Now you can press the Debug icon (looks like a play arrow) in Qt Creator and it will automatically scp the binary to the BeagleBone and start a remote GDB server session.
Create a GUI Project
Under the Welcome page, Click the "New Project" button
Select "Applications" from the list on the left
Select "Qt Gui Application"
Note: This option may not show up. If Qt Creator does not see the Qt 5.2 build as supporting GUI applications, you can choose "Qt Widgets Application", but this may give different results. The other option is to install a distro version of Qt and make Qt Creator aware of it. This will make the Gui option visible in the project creation section. Nevermind, this is a difference between Qt Creator 2.8 and 3.0. The source generated, for either option, is identical.
Click the "Next" button
Enter "HelloWorldGUI" in the name field
Change the target directory, if you like
Click on the "Next" button
Review the details and then click on the "Next" button
Click on the "Finish" button
Modify Auto-Generated Project
Perform the same .pro file changes, as the console project, to deploy the project to the Beaglebone.
I can't execute gui applications directly on Ubuntu. Is there any way to do it? Do i need to kill ubuntu's graphic interface? If so how can i do it?
ReplyDeleteI also would like to know the best way to calibrate my pointer. I am using a LCD4 BBB Cape.
Thank you so much for your tutorial.
Sorry, I wasn't more clear, but I am not running X. You need to have X shut down in order to use the example GUI apps.
ReplyDeleteYou can get Qt to work with X, but that is not my goal. But, if I can figure out how to add support for X, I will document it here.
Louis i've tried to run a Simple GUI application with two buttons, however the button's text are invisible.
ReplyDeleteThe image didn't scale well also and the touchscreen didn't work.
I am using the 4D System LCD Cape. I've used the Qt Widget Application and inserted two buttons in it :)
Thank you very much.
My dmesg gives me this:
Delete251.181223] idr_remove called for id=154640 which is not allocated.
[ 251.181340] [] (unwind_backtrace+0x1/0x8a) from [] (idr_remove+0xc5/0x120)
[ 251.181418] [] (idr_remove+0xc5/0x120) from [] (drm_ctxbitmap_free+0x1b/0x24)
[ 251.181478] [] (drm_ctxbitmap_free+0x1b/0x24) from [] (drm_rmctx+0x31/0xa0)
[ 251.181535] [] (drm_rmctx+0x31/0xa0) from [] (drm_ioctl+0x1d9/0x28a)
[ 251.181599] [] (drm_ioctl+0x1d9/0x28a) from [] (do_vfs_ioctl+0x3b9/0x402)
[ 251.181654] [] (do_vfs_ioctl+0x3b9/0x402) from [] (sys_ioctl+0x33/0x44)
[ 251.181714] [] (sys_ioctl+0x33/0x44) from [] (ret_fast_syscall+0x1/0x46)
Your results are the same as mine: GUI applications don't work. I am still working on it. I tried a couple of Font tests, but still haven't narrowed down why they are not showing up.
DeleteThere is a rumor that Qt 5.2.0 has a bug with respect to the touchscreen. Something about the initial screen reported to drivers is a rectangle: 0,0,1,1. This may be why scaling is off too.
I am currently working on getting plug-ins and modules to work. I have the alsa module getting recognized, next is either more modules (PulseAudio, FontConfig, etc) or the tslib plugin.
Cool Luis, can i help you with that? I've added you to g+.
DeleteThat would be awesome! We can discuss it through G+, but just let me know what you want to tackle and I will work on something else :)
ReplyDeleteI'm going to look into some of these (http://qt-project.org/forums/viewthread/36120) configuration options.
Thanks for going to the effort to create this tutorial. I have been looking for a non-Angstrom target qt for ages.
ReplyDeleteMy target is Debian 3.2.13-bone31. I'm guessing that your method will be ok for that target?
Can you tell me how the TI graphics SDK fits into all of this? You mention it in part1, but I see no subsequent mention.
Thanks
Ivo
You're welcome.
ReplyDeleteThat target should be fine.
I was going to get the SDK running, and I spent a lot of time on it, but the graphics processor is not getting started in the current 3.8 kernels. So I went through all that effort, but it is going to take a lot more.
I guess SGX it is working under 3.12, but then some of the other beaglebone code is not (like Xorg)....so it is your choice.
I may come back to it, but I'm still working on base Qt functionality.
I should clarify, accelerated Xorg is not working, as well as capemgr. But that is as of a couple weeks ago.....maybe things have changed.....
ReplyDeleteThanks, I notice a typo in my version. Should be 3.8.13-bone31
DeleteI'm looking forward to hearing of your progress!!
Hi Louis,
DeleteI have got everything built and transferred to the beaglebone (with Debian) as per your instructions. The first problem I had was that the Qt libraries couldn't be found. This I solved by putting the path in /etc/ld.so.conf and running ldconfig. The latter complained that a number of the libraries were not symbolic links, but nevertheless the example dnslookup worked fine. I think the reason for the symbolic link error is that in the /usr/local/qt-5.2/lib directory there are heaps of libraries with different names that are really identical (same md5sum). I think these should be converted into symbolic links.
Anyway I have not been able to run the analogclock example. I get the error:
This application failed to start because it could not find or load the Qt platform plugin "linuxfb".
How do I address this missing blugin?
Thanks for your help
regards
Ivo
The Qt apps are looking for the plugins in the same path that you built them to install at. If you followed my instructions to the letter, that would be /usr/local/qt-5.2. I think you might be able to tell the apps to look somewhere else, but I can't say that for sure. The other option is to build Qt again, this time with the directory you really want to install it to on the target.
ReplyDeleteThe Qt apps are looking for the plugins in the same path that you built them to install at. If you followed my instructions to the letter, that would be /usr/local/qt-5.2. I think you might be able to tell the apps to look somewhere else, but I can't say that for sure. The other option is to build Qt again, this time with the directory you really want to install it to on the target.
ReplyDeleteThanks Louis - spot on. I was missing a '/' in my -prefix option :-(. You are a good man!
ReplyDeleteThanks for this tutorial.
ReplyDeleteDid you tried to compile and run a QML app on the BBB ?
It uses OpenGL ES and I guess your tutorial doesn't support this part ?
Am I right ?
Thanks
AleX.
You are correct. I will try to get OpenGL working with Kernel 3.12.
DeleteI've been sidetracked for a while, because I was fighting hardware issues with the BB-View 7. But now that those are solved, I should be getting back to Qt stuff soon.
Still, I'll try to compile Qt5.2 at least for QtWidgets.
DeleteThanks
nice done Louis. Whenever I was looking to be able to use GUI part of Qt . Now your cape is done, did you found the time to get GUI working on a touchscreen? (4D Systems Touch in my case)
ReplyDeleteBR
Can I run QtSerialPort application on Beaglebone Black Louis.??
ReplyDeleteIf so can you explain me how or can you write it on your blog please. Your reply is well appreciated.
Yes, I have run several different modules: QtSerialPort, QhttpServer, etc. You have to compile them with your toolchain. If the module has a .pro file, you can simply open the project in Qt Creator and build it that way. Otherwise, you need to setup the build environment from a shell. I cannot remember all that is involved with that, at the moment, but it was fairly painless.
ReplyDeleteDear Sir, First of all thanks a lot for this informative blog. I have follow the steps as per your blog and got the success. Example and some application made by me are working perfectly but there is one problem that whenever i execute the application on the Beagle bone black, it makes the screen unresponsive. I can not move the cursor and also i can not close the application. The screen just stays on the top. Can you please tell me how i can close the app. thanks
ReplyDeleteYou're welcome! That is a known issue and I worked around it by running the app via a ssh or serial console. This way you can kill it with CTRL-C or log in with another terminal and issue a kill command.
DeleteThanks for the prompt response. I am also using SSH. With your help i proceeded in my project and now i made a GUI, which is displaying the data acquired from a device on the graph. I used qCustomPlot. But there is one problem, when i am trying to display the data on graph, no dialog appears, just the screen hangs. I can see the data on the terminal acquired from the device but i can't see any QT dialog. Any suggestion will be helpful.
DeleteThank you for such a nice tutorial it was quite helpful. I have installed qt5 and latest Linaro toolchain for my BBB. I am able to compile it as well and run as well. I have a problem now with GDB (I guess).
ReplyDeleteI am creating a simple console application to test if I will be able to go into debug mode and will be able to deploy the file or not. It is as usual a simple Hello World program. The way I understood it, when I will press the run button it should deploy the application to the BBB and I should be able to see Hello World written on the console of my BBB and in debug mode should be able to see the registers etc but I can not. When I go into debug it prints a Hello world in the Application output with the following message.
Debugging starts
stdin: is not a tty
Process /root/HelloWorld created; pid = 2322
Listening on port 10000
Skipping deprecated .gdb_index section in /home/naqqash/qt-projects/build-HelloWorld-BBB_kit-Debug/HelloWorld.
Do “set use-deprecated-index-sections on” before file is read to use the section anyway.
Remote debugging from host 192.168.7.1
Hello World!
May be someone can guide me in the right direction. I am using a Ubuntu virtual machine where I am checking the BBB through SSH. Should I need to disable something in BBB or it is because I am checking it through SSH , I should connect a display??
May be “use-deprecated-index-sections on” has to do something with it.
Regards,
Naqqash