Cross Compiling Qt onto Pi problems
Hello, I have been searching around for the best way to be able to develop on the Pi. My programs are Qt based, and take a while to compile on the Pi itself (qt 4). I decided that I need to cross compile. There are many links that have told me similar things.
Essentially I need:
- QT5 sources
- Toolchain (https://github.com/raspberrypi/tools/)
- Raspbian image
I used VirtualBox to put Ubuntu on my windows PC. Then i installed QT creator and QT5 for Ubuntu. I get confused where they say I need a new Raspbian image and I need to mount it. **What does mounting the image do? **Can I just take the SD card I am already using? I feel like Im playing with Russian Dolls with my operating systems. Raspbian in Ubuntu in Windows....
I already have qt4 on my Pi, so do i need to build qt5 from source? I hear that takes a long time. Do I need to copy those files over from my Pi to Ubuntu?
Hi and welcome to devnet,
"mounting the image" is essentially the same as mounting an USB mass storage device (or any other storage for that matter).
Yes, you can use your SD Card.
If you want to use Qt 5, then yes you have to cross-compile it first. It can take a long time if your computer is slow. It's really slow if you compile it natively on the Pi.
The copying part will take place automatically when you call
Hope it helps
Thanks for the reply.
I am getting confused as to which parts parts of the tutorials are done on the Pi, and which are done on the Ubuntu side. I was able to mount the raspberry pi image which has qt4 on it.
In Qt Creator, I need the Qt version, and the compiler. I am having trouble knowing which to pick.
I was able to cross compile a non-Qt hello world program using this tutorial. http://jeremy-nicola.info/portfolio-item/cross-compilation-distributed-compilation-for-the-raspberry-pi/
But that was using the compiler on the Ubuntu side. Is the reason that I have to build and mount Qt on the Pi because I have to navigate to the Qt version on the Pi img?
I tried to add the qmake from the Pi and it gives me this error,* "The qmake executable /home/bradley/SharedWindows/img2/usr/bin/qmake-qt4 could not be added: Cannot start "/home/bradley/SharedWindows/img2/usr/bin/qmake-qt4": Exec format error"*
It's a native Qt 4 that you have on your Pi filesystem, it won't run your desktop. To cross-compile you need to have your Pi root file system mounted as it provides with the necessary libraries.
I have the Pi root file system mounted and I am able to navigate through. Which library files am I looking for? Do these go under the Qt Version setting or the compiler setting?
Did you call make install after you cross-compiled Qt ?
Forgive me if this sounds stupid, but if I have Qt4 installed on the Pi from downloading the binaries (https://wiki.qt.io/Apt-get_Qt4_on_the_Raspberry_Pi), then I didnt think I needed to compile Qt again. Does that package not have what is required?
Again, it's the native package for the Pi so compiled for ARM including the tools like qmake, you can use it directly on the Pi but not on your desktop machine (the error you got earlier comes from that)
Ok, I think I got a little bit further. I have done this tutorial
I was able to mount the RPi root system, and I am on the example part. There isnt a make file on that page. There is an image though. After the word "make" in the command line, there is a lot of text. This is essentially the make file right?
I am trying to apply what I have now with qt creator and looking at the Configuring Qt Creator part here, http://raspberry-qt.org/#binaries
Im at the line, "Click "Add..." and select "/usr/local/qt5pi/bin/qmake""
and its saying I need to run make install. You mentioned that before. But if I try to do that, it says,
bradley@bradley-VirtualBox:~/rpi/2013-03-22-raspberry-qt/qt5pi/bin$ make install
make: *** No rule to make target `install'. Stop.
And if I wanted to use qt4, then I need the qt4 folder like that theirs. what is it? How did they create that folder? Is it just downloaded from the qt website?
Thank you for all of the guidance!
You should call
make installin the same folder you called make before.
Qt 4 is natively build for ARM. Raspbian is a Debian derivative and thus gives access to a lot of packages. However if you want to use your desktop computer to build Qt 4 application for the Raspberry Pi you again need to first cross-compile Qt 4.
I have gone through many guides to cross compile QT4 on x86 but none is complete
so please if possible can you explain the procedure to cross compile QT4 for ARM
sorry for my english.
What did you do ? What didn't work ?
I have followed this link
but it is using make file for cross compiling the application whereas I want to build Qmake and configure Qt Creator for cross compilation.
Did you first cross-compile Qt 4 ?
Hi! I have a problem with configuration Qt5 on Raspberry Pi with Raspbian. I follow this instruction: https://wiki.qt.io/Native_Build_of_Qt5_on_a_Raspberry_Pi and after I called instruction ./configure -v -opengl es2 -device linux-rasp-pi-g''+ -device-option CROSS_COMPILE=/usr/bin/ -opensource
-confirm-license -optimized-qmake -reduce-exports -release -qt-pcre -make libs -prefix /usr/local/qt5 &> output, the process didn't stop. I was waiting about 1 hour and process 'cc1plus' still was performing, so is there other way to configure qt5 for cross-compile?
Note: I didn't use patch file from the instruction.
Edit: I switched off Raspberry and next day, the same instruction took few seconds. But I'm not sure if the 'output' file is ok. my output looks diffrent than output file from the example in instruction, is that normal?
But there is other problem: next instuction: 'make &> output_make' takes few hours and it did't stop so I killed it. This time output_make file is very big and it's growing while processing, so how long should it process?
I tried cross compiling Qt 5, And I got about 2 hours into it when I got this message.
I dont really know what this means. Did it complete? What do the error 1 and 2s mean?
../../../../mkspecs/devices/linux-rasp-pi-g++/qeglfshooks_pi.cpp:95:68: error: declaration of C function ‘int vc_dispmanx_element_change_attributes(DISPMANX_UPDATE_HANDLE_T, DISPMANX_ELEMENT_HANDLE_T, uint32_t, int32_t, uint8_t, const VC_RECT_T, const VC_RECT_T*, DISPMANX_RESOURCE_HANDLE_T, VC_IMAGE_TRANSFORM_T)’ conflicts with
In file included from /mnt/raspberry-rootfs/opt/vc/include/EGL/eglplatform.h:110:0,
/mnt/raspberry-rootfs/opt/vc/include/interface/vmcs_host/vc_dispmanx.h:108:22: error: previous declaration ‘int vc_dispmanx_element_change_attributes(DISPMANX_UPDATE_HANDLE_T, DISPMANX_ELEMENT_HANDLE_T, uint32_t, int32_t, uint8_t, const VC_RECT_T*, const VC_RECT_T*, DISPMANX_RESOURCE_HANDLE_T, DISPMANX_TRANSFORM_T)’ here
../../../../mkspecs/devices/linux-rasp-pi-g++/qeglfshooks_pi.cpp:195:10: warning: unused parameter ‘window’ [-Wunused-parameter]
In file included from ../../../../mkspecs/devices/linux-rasp-pi-g++/qeglfshooks_pi.cpp:42:0:
./qeglfshooks.h:74:21: warning: ‘hooks’ defined but not used [-Wunused-variable]
make: *** [.obj/release-shared/qeglfshooks_pi.o] Error 1
make: Leaving directory
/home/bradley/raspberry/qt-everywhere-opensource-src-5.0.2/qtbase/src/plugins/platforms/eglfs' make: *** [sub-eglfs-make_first] Error 2 make: Leaving directory/home/bradley/raspberry/qt-everywhere-opensource-src-5.0.2/qtbase/src/plugins/platforms'
make: *** [sub-platforms-make_first] Error 2
make: Leaving directory
/home/bradley/raspberry/qt-everywhere-opensource-src-5.0.2/qtbase/src/plugins' make: *** [sub-plugins-make_first] Error 2 make: Leaving directory/home/bradley/raspberry/qt-everywhere-opensource-src-5.0.2/qtbase/src'
make: *** [sub-src-make_first] Error 2
So....after running into more problems with the other online tutorials, I went back to the original Qt wiki tutorial. When I first looked at it months back, I couldnt follow it through, so I looked for other ways. This time, I was able to understand and navigate through the steps. I can now cross compile Qt programs from my Windows PC!
I used Ubuntu in VirtualBox, with a Raspbian image mounted! (Raspbian->Ubuntu->Windows)->Raspbian
Thanks for the help here on the forums. Its been months of reading and learning about linux.
For anyone who wants to do the same, you can contact me.
I did notice two things not mentioned on the wiki page.
First, that there was a path error. Wherever it uses "/mnt/rasp-pi-rootfs", it should be "~/opt/mnt/rasp-pi-rootfs"
I wouldnt have known how to spot the error or how to fix it without the arduous process of learning linux.
Second, after you unmount the root filesystem after cross compiling Qt5 and put it onto the SD card, the Raspberry will not boot. Dont worry, just do what it asks:
password, then type "fsck"