Qt5.1 on Rasberry Pi (full install not cross-compile)
I would like to install Qt5.1 on my RPi.
My RPi has Raspbian.
I don't want to cross-compile. I really want a full installation on the RPi.
Can anyone help me with this?
The only info i found is about cross-compile and for me (little experience with linux) it's very confusing.
Copy the source code onto the device, then use compilation instructions for Linux.
Doesn't the Qt installer from the downloads page work? I'm interested in Qt 5.1+ too.
I have set up a Linux PC with the 5.1, and done a few modifications to the beginning of my code. Mainly due to QT += changes in the .pro file, and some #include changes. Yes, the app now uses OpenGLES2. Now it would be good if I could also develop on the Pi too, with a hardware acceleration and webkit.
I decided to use ALSA for sound as I need realtime rendering, and not just samples. Are you sure the Pi has enough memory to compile the sources?
Qt precompiled stuff is compiled for x86, Raspbery uses ARM architecture. It won't work. You need to compile (or crosscompile) yourself.
I have the same problem. I tried to compile it for 4 times, with no success.
My question is. Nobody can compile it and put on the cloud a working OS?.
Compiling on the raspberry pi is easy. Please follow my directions here:
Install packages needed for compiling:
sudo apt-get update sudo apt-get upgrade sudo apt-get install libfontconfig1-dev libdbus-1-dev libfreetype6-dev libudev-dev libicu-dev libsqlite3-dev libxslt1-dev libssl-dev libasound2-dev libavcodec-dev libavformat-dev libswscale-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev gstreamer-tools gstreamer0.10-plugins-good gstreamer0.10-plugins-bad libraspberrypi-dev libpulse-dev libx11-dev libglib2.0-dev libcups2-dev freetds-dev libsqlite0-dev libpq-dev libiodbc2-dev libmysqlclient-dev firebird-dev libpng12-dev libjpeg62-dev libgst-dev libxext-dev libxcb1 libxcb1-dev libx11-xcb1 libx11-xcb-dev libxcb-keysyms1 libxcb-keysyms1-dev libxcb-image0 libxcb-image0-dev libxcb-shm0 libxcb-shm0-dev libxcb-icccm4 libxcb-icccm4-dev libxcb-sync0 libxcb-sync0-dev libxcb-render-util0 libxcb-render-util0-dev libxcb-xfixes0-dev libxrender-dev libxcb-shape0-dev libxcb-randr0-dev libxcb-glx0-dev libxi-dev libdrm-dev
Then make your build directory:
mkdir ~/opt cd ~/opt
Retrieve qt5 source code from git:
git clone git://gitorious.org/qt/qt5.git
Retrieve git sources for other components
cd qt5 ./init-repository
Do not apply any patches. I got messed up with this part. The git source should compile with a few tricks in the configure parameters. First make sure you are in the qt5 directory.
Configure qt5, you need to point the CROSS_COMPILE variable to /usr/bin/g++ (without the g++) otherwise it will complain that it is not being cross_compiled (this is a hack/trick). All output is stored in the file called 'output' in case something goes wrong. At the end of the output file it should say you can run 'make', if not look for errors at the end of the output but do not be concerned with some things not building due to missing packages, there will be errors for those. The last error is the show-stopper.
./configure -v -opengl es2 -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=/usr/bin/ -opensource -confirm-license -optimized-qmake -reduce-relocations -reduce-exports -release -qt-pcre -make libs -prefix /usr/local/qt5 &> output
Check the output file to see that it is building the components you need and that you can now run make. If not you may need to tweak your ~/opt/qt5/qtbase/configure script. I didn't have all of the dependencies installed when I first ran (so try the above first before changing your configure script) and I had to change the following in the ~/opt/qt5/qtbase/configure script (search for QT_CFLAGS_DBUS):
# flags for raspberry pi build # flags for libdbus-1 QT_CFLAGS_DBUS="-I/usr/include/dbus-1.0/ -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include/" QT_LIBS_DBUS=-ldbus-1 # flags for Glib (X11 only) QT_CFLAGS_GLIB="-I/usr/include/glib-2.0/ -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include/" QT_LIBS_GLIB=-lglib-2.0 QT_CFLAGS_PULSEAUDIO="-I/usr/include/glib-2.0/ -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include/" QT_LIBS_PULSEAUDIO="-lpulse -lpulse-mainloop-glib" # flags for GStreamer (X11 only) QT_CFLAGS_GSTREAMER="-I/usr/include/gstreamer-0.10/ -I/usr/include/glib-2.0/ -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include/ -I/usr/include/libxml2/" QT_LIBS_GSTREAMER=
Search for QT_CFLAGS_FONTCONFIG in the configure script. It should be below the above entries, you need to change this one in the if statement to this:
Then you need to run make as follows (check for errors in the output_make file):
make &> output_make
If that is good then run make install (check for errors in the output_make_install file):
sudo make install &> output_make_install
After this you need to add some lines to your .bashrc file:
export LD_LIBRARY_PATH=/usr/local/qt5/lib/ export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/qt5/bin
You need to source your .bashrc file to set-up the above environment variables:
Then run this and check that it points to /usr/local/qt5/bin/qmake
After this you should be able to compile the sample applications and run them. Try the OpenGL Cube:
cp -r ~/opt/qt5/qtbase/examples/opengl/cube ~/ cd ~/cube qmake make ./cube
If I made any typos in the above post, please let me know. I tested this with the May 23rd version of Raspbian and it compiled fine.
I should add that it takes 2 days to compile with make on the raspberry pi. The configure and make install are fairly quick. I now have a pi that I can run qmake on and it works with OpenGL ES.
This is ultra cool :) I recommend you create a wiki page from this post :D
I would like to, but I'm ignorant of the process. Could someone help and give me a bit of guidance?
You can create a new wiki page by going "here":http://qt-project.org/wiki and clicking on "Create new page" in the right side-pane.
Thanks for the wiki tip sierdzio. Regarding the compilation links, and I mean this with all due respect, those links are not native builds, they are cross compiled builds. The instructions I have posted are for building everything on the Raspberry Pi itself without any dependency on a host/desktop system.
You can create a new wiki page by going "here":http://qt-project.org/wiki and clicking on "Create new page" in the right side-pane.[/quote]
I know, I just linked them so that you are aware of them ;) I think both are rather outdated, too.
OK, the wiki page is done!
Can someone please test this with a clean raspbian image and let me know if the configure script changes are still necessary?
I hope this helps everyone.
Thanks, I've tagged the page. I'll probably test once I get a Raspberry.
Thanks, for your answer postmako.
I'll try again, with your guide,
Thanks for your input, sierdzio and postmako.
I'm trying to build using some instructions i had previously found (using some from cross-compile using a desktop machine and for build to Linux desktop).
It´s already compiling for almost a day now (after 2 unsuccessful attempts). If it doesn't work i will try postmako approach.
Once again, thanks for your instructions postmako, because the only instructions i could find related to the RPi were using cross-compile with a desktop machine.
Yeah let me know how the instructions work for you. Note that you should use the instructions at the wiki link because I have updated and corrected them when I ran the compilation a second time. The configure script changes are required in order to get it to compile those modules.
I'm now following your instructions because my other attempt failled after 2 days compiling...
I started last night, so it's been compiling for only 24h. Tomorrow i will let you know how it went.
Tell me one thing, because i want to build apps using the X windows, not from console, do i need to do the part related to the .bashrc? You should also say this in the wiki you created and if it's necessary to do anything else for x windows.
On your instructions i have 4 remarks:
1- you should include that it's necessary to do sudo apt-get install git (if it's not installed), in order to use git.
2- when you say "Then before closing the file search for QT_CFLAGS_FONTCONFIG in the configure script. It should be below the above entries, you need to change the one in the if statement to this:"
If i understood correctly you should say it's in the else (which is empty) part of the if .
3- you should say where .bashrc is located and the full file name bash.bashrc.
4- previously stated about X windows.
I only stated some things that may be obvious for those who are used to Linux, but not for me (little experience on Linux).
Once again, thanks for your instructions.
- Did you use the May 23rd Raspbian version? Mine had git installed already.
- Yeah, this is a bit unclear and that is why I included the diff file.
- Yeah the .bashrc I was referring to is located at ~/.bashrc but you can modify the bash.bashrc file as well (at least I think you can.) Let me know if it works.
- I'm not sure what else you need to do for x-windows but I think you still need the directories set-up in the .bashrc file even for x-windows otherwise it will not know where qmake or Qt5 is located.
I wasn't using May 23rd version, i was using one older.
I asked about .bashrc, because i couldn't find it, because it's a hidden file (at least in my version it's hidden).
My installation was ok and i could run the cube example like you said.
But now i have two other problems.
I can't find the qtcreator exec in X windows.
The second one is that i need to use qtserialport and when i tried to build the example project using terminal i get unknow module in Qt: serialport. Why is that? In my other machine, running Ubuntu, when i installed Qt5.1 all modules (including qtserialport) are installed.
Can you help me with these 2 problems?
Thanks for your time.
To get qtcreator follow these instructions but use your Qt5.1 instead of Qt4 like the instructions state: "http://www.raspberrypi.org/phpBB3/viewtopic.php?f=31&t=43545":http://www.raspberrypi.org/phpBB3/viewtopic.php?f=31&t=43545
After you try that, please let me know if it works for you or not. I will probably try it if I find some time.
I'm able to compile with QtSerialPort, could you post your source code and the "*.pro" file for it? If that looks good then I would like to see your "output" file from the compilation to see if something got missed or skipped over. It could also be that your older version of Raspbian doesn't support it. It's hard to say and maybe someone who is more informed than me could help you.
The instructions you told me, i think they will install for Qt4, because using
- sudo apt-get install Qtcreator
it will install Qt creator 2.5 (Qt4.8)
but i will try it...
Related to qserialport, i tried to build the example project enumerator and it gave me the error.
For qserialport i think i have to build the module.
I will try qmake, make and make install for the module.
For Qt creator 2.7 i think it will also have to be built, not exactly sure how.
I will try to get it from git and after using also qmake, make and make install.
Let's see how it goes...
For qserialport i tried to build the module like i said in my previous post, it compiled the module but when i tried the example enumerator, i get as before, unknown module.
Please post your .pro file and make sure you have this line in it:
QT += serialport
Rerun qmake, then make.
Also, you do NOT want to follow those instructions on Raspberry Pi. I just tried and couldn't get Qt5 to work with it because it installs QtCreator 2.5 and you need 2.6.1 to run Qt5.
Compiling that for the Raspberry Pi seems like another good wiki.
I'm starting the build from git for version 2.8.0:
git clone git://gitorious.org/qt-creator/qt-creator.git
I just ran this but getting an error:
Project ERROR: Unknown module(s) in QT: designercomponents designer@
Qserialport is already working.
I had forgot to do sudo make install.
Now Qt creator is another thing...
Looking at your previous post, it seems you might have to build and install that module...
Tomorrow (here its 2 a.m.) i will try it also.
Also, can you tell me how can i close the window when i run my app?
I get it fullscreen...
I tried what you did but i get a different error:
- Project ERROR: Unknown module(s) in QT: script
Not sure on those unknown module errors. I'll have to look at them when I get more time.
Regarding the closing the app, if you are in the console Ctrl+Alt+Backspace works, Ctrl+C might work as well. In x-windows, I haven't figured out which key combo works but in your app you can add a this->close(); in the main window class wherever appropriate.
I'm now trying to compile and install qtscript module and after if i get your error i will do the same with qttools (it seems to be related to designer).
Yeah I was pretty sure mine compiled qttools because the .obj directory is populated (FYI - In Linux anytime a file or directory starts with a period (.), the file or directory will be hidden), but it still complains about designer. I ran qmake without the -r and then I'm running make now. Quite an experiment from two rather inexperienced Qt bit diddlers eh? I'm a software engineer by trade but this is the first time I've used Qt.
I am currently compiling qt as written in the wiki, but I had to leave the configuration file vanilla. When I applied the changes the configure script stopped telling me something about an unterminated string.
I hope the compilation will be finished on monday :o)
I also would like to use qt designer, so i somebody knows how to compile it I would be happy!
Just an FYI, if you don't manually make the changes to the configure script then it will not build PulseAudio, DBus, or some of the others.
Did you had any luck on Qtcreator?
Mine first complainned about: unknown module: script.
I build and installed qtscript module. This error resolved.
Next try i got unknown module:declarative.
I build and installed qtdeclarative module and also qttools, but i still get unknown module: declarative.
As i can see it will be necessary to build and install some other modules...
The problem is that it's complainning about declarative but i already build and installed it...
Sorry no, I need to learn more about this before getting any further as well.
The only info i found on the web states that declarative module was renamed to quick, but this was on Qtcreator 2.6....
[quote author="postmako" date="1375481184"]Just an FYI, if you don't manually make the changes to the configure script then it will not build PulseAudio, DBus, or some of the others.[/quote]
THX for the hint. Somehow changing the file manually did not work, using the patch file didn´t work either:
pi@raspberrypi ~/opt/qt5 $ patch -p0 < raspberry.patch
patch: **** Only garbage was found in the patch input.
Same when putting the patch file into the qtbase dir and calling patch there. I have no idea what the problem is.
It would be nice if the patch file could be downloaded and the right "patch" command would be given. I used patches on the linux kernel 1000 times, but seems I an unable to get this little thing working here. :-/
Click on my profile and send me your configure script, I'll try to see why yours is different.
I still didn't managed to build Qtcreator.
After build and install qtquick1 module the declarative error was resolved. But now i get the same you had: designercomponents designer.
One other thing, is it possible when building an app, define it not to use opengl?
My problem is that i want to show my app (running on RPi) on my laptop (not on monitor), using x11vnc and tightvncviewer. I get the same screen as pi, but i can't get the hdmi output because of opengl.
Is there any way to do it, or should i build again Qt and in configure do not use -opengl es2?
As far as I know adding the -opengl es2 to the configure is just telling Qt to configure opengl for ES2 not the desktop. It should not matter when it comes to building your apps. There is probably something wrong with your application.
Did you try building the sample apps in /home/pi/opt/qt5/qtbase/examples/ ?