Compiling on the raspberry
https://qt-project.org/forums/viewthread/30331/
Compiling on the raspberry pi is easy. Please follow my directions here:
Install packages needed for compiling:
Then make your build directory:
Retrieve qt5 source code from git:
Retrieve git sources for other components
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.
Run configure:
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):
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):
If that is good then run make install (check for errors in the output_make_install file):
After this you need to add some lines to your .bashrc file:
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:
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.
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
- mkdir ~/opt
- cd ~/opt
- git clone git://gitorious.org/qt/qt5.git
- cd qt5
- ./init-repository
- cd ~/opt/qt5
Run configure:
- ./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
- # 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=
- QT_CFLAGS_FONTCONFIG=-I/usr/include/freetype2/
- make &> output_make
- sudo make install &> output_make_install
- 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
- source ~/.bashrc
- which qmake
- cp -r ~/opt/qt5/qtbase/examples/opengl/cube ~/
- cd ~/cube
- qmake
- make
- ./cube
评论