QT Installation Guide: This Document Guides The User Through
QT Installation Guide: This Document Guides The User Through
by Brian Fraser Last update: November 7, 2011 This document guides the user through: 1. Building and installing Qt on for the host (native) and target (cross-compile) environment. 2. Building Qt applications for each target.
Table of Contents
1. Download Packages...............................................................................................................................2 2. Touchscreen library:...............................................................................................................................2 3. Cross-Compiling the Qt Framework......................................................................................................6 4. Qt Framework Native Host Installation.................................................................................................8 5. Cross-Compiling Qt Application...........................................................................................................9 6. Native Compiling Qt Application........................................................................................................10 Caution: This guide has not yet been tested in the SFU Surrey Linux Lab (SUR4080). Some changes may be needed. Do not attempt any of the "sudo" commands in the SFU Linux Lab. You do not have permission to do so, and it notifies our IT staff. If something is not setup, please email me and I'll ask them to set it up for us.
2. Almost all commands are case sensitive in Linux and U-Boot. Revision History: Nov 6: Initial version. Nov 7: Updated based on feedback: Corrected many references to the public folder and changed to private folder. Changed /sbin/test to /sbin/ts_test Made some copy commands recursive.
Qt Installation Guide
1 / 10
1. Download Packages
1. Install the autoconf tools (do not try in Linux lab; see caution on front page):
> sudo apt-get install autoconf libtool
From https://github.com/kergoth/tslib download: The small "ZIP" button is near the top of the web page, on the left-hand side. The ???'s will be replaced with letters in the file you download.
2. Touchscreen library:
1. Change to the tslib source directory:
> cd ~/cmpt433/private/tslib-src
6. Copy tslib executables to root-files-system (RFS) on host. This assumes that your RFS is named fs-qt4.7.3 The executables include:
ts_calibrate:
Utility to calibrate the touch screen. program to test the touch screen.
Copy the contents of /tslib/bin into .../fs-qt4.7.3/sbin/ Replace any existing files.
2 / 10
Qt Installation Guide
Copy the contents (and sub-folders) of /tslib/lib into .../fs-qt4.7.3/lib Merge with existing content; replacing duplicate files.
7. Configure the Touchscreen (and Qt) Place the following content in a new file named qt_env.sh under the /etc directory in your root file system on the host:
> gedit ~/cmpt433/private/fs-qt4.7.3/etc/qt_env.sh
#!/bin/sh # Environment variables for TouchScreen: export set TSLIB_TSDEVICE=/dev/event0 export set TSLIB_CONFFILE=/etc/ts.conf export set TSLIB_PLUGINDIR=/lib/ts export set TSLIB_CALIBFILE=/etc/pointercal
# Qt Configuration: export set QWS_KEYBOARD="TTY:/dev/tty1" export set QWS_MOUSE_PROTO="tslib:/dev/event0 IntelliMouse:/dev/mice" export set LD_LIBRARY_PATH=/opt/qtlibs/ export set QT_QWS_FONTDIR=/opt/qtlibs/fonts
8. Place the following content in a new file named launchqt under the /sbin directory of your RFS on the host:
> gedit ~/cmpt433/private/fs-qt4.7.3/sbin/launchqt
#!/bin/sh # Short script to launch a Qt application and # the touch-screen calibration (if necessary). if [ ! -f /etc/pointercal ] ; then echo "Calibrating TouchScreen..." /sbin/ts_calibrate fi if [ $# -gt 0 ] ; then $1 -qws fi
Still in rcS, add the following lines which will: "source" the above configuration file, setting up the runtime environment to launch Qt applications (setting up the fonts, the touch screen, ...) during startup; and launch the touch-screen to calibrate at start-up if required
Qt Installation Guide
3 / 10
Only have one call to launchqt in your start-up process. Call the script without an argument to just run the touch-screen calibration (if required). Or pass it the filename of a Qt program to have it launch it after the touchscreen calibration is complete.
Add the following which will allow you to launch Qt applications directly from the command line without setting any extra environment parameters:
source /etc/qt_env.sh
12. Build the RFS and download it to the board; boot the board. See the quick-start guide from earlier in the semester for directions. When Linux reboots, it should now show you the touch-screen calibration screen automatically. The calibration will only run once each time you download a new root file system.
13. Test the touchscreen on the target: > /sbin/ts_test This should display a simple drawing application. When you move your finger around on the screen, the cursor should respond and follow your finger reasonably well. Test that touch-screen gives input by running the following on the target:
> cat /dev/event0 | hexdump
It should get numbers/text on the screen each time you press the screen. If it does, it means your hardware is working correctly and that Linux is correctly configured. Otherwise, ensure the kernel is correctly configured with the touch-screen drivers. In the kernel sub-directory:
> make menuconfig
Under: Device Drivers --> Input device support: Horizontal screen resolution: 320 Vertical screen resolution: 240 <*> EmbedSky TQ2440 TouchScreen input driver <*> Support for frame buffer devices --> <*> S2C2410 LCD framebuffer support
Under: Device Drivers --> Touchscreen Under: Device Drivers --> Graphics support
Qt Installation Guide
If you made any changes, rebuild your kernel and re-download it and retry the above hardware test.
Failing this, the LCD cable on target may need to re-seated; talk to instructor. I do not recommend you try this yourself.
The touch-screen calibration should only run once each time you re-download the root-file system. If it does not run, check the following. Prove that the file is there by manually running the calibration:
> ts_calibrate
Ensure that your target's RFS has both necessary script files (and are correct):
> cat /etc/qt_env.sh > cat /sbin/launchqt
Ensure that the start-up file has been setup to correctly source qt_env.sh and launch launchqt:
> cat /etc/init.d/rcS
Check that the environment variables defined in qt_env.sh are defined on the target:
> printenv
If they are not defined, ensure you edited your /etc/profile file correctly:
> cat /etc/profile
It may include many commented out lines (with #) but should include at least:
module_raw input module pthres pmin=1 module variance delta=30 module dejitter delta=100 module linear
Qt Installation Guide
5 / 10
Uncomment line 238, "typedef __intptr_t intptr_t;" Uncomment line 996, "extern void *sbrk...." Edit the file ~/cmpt433/private/qt-everywhere-opensource-src4.7.3/mkspecs/qws/linux-arm-g++/qmake.conf
Add the following lines before the "load(qt_config)" line. Note: Lines ending with \ are to continue on the next line.
QMAKE_CFLAGS_RELEASE += -O0 -msoft-float \ -D__GCC_FLOAT_NOT_NEEDED \ -march=armv4t -mtune=arm920t -mcpu=arm920t QMAKE_CXXFLAGS_RELEASE += -O0 -msoft-float \ -D__GCC_FLOAT_NOT_NEEDED \ -march=armv4t -mtune=arm920t -mcpu=arm920t # Ensure it's Optimization level 0: QMAKE_CFLAGS_RELEASE -= -O2 QMAKE_CXXFLAGS_RELEASE -= -O2 # Getting Touch Screen (tslib) working: QMAKE_INCDIR += /home/YOURID/cmpt433/private/tslib/include QMAKE_LIBDIR += /home/YOURID/cmpt433/private/tslib/lib
Note that the QMAKE_INCDIR and QMAKE_LIBDIR must both be full paths; you can't use "~" or $HOME. Change YOURID to be your real user ID.
> ./configure -embedded arm -xplatform qws/linux-arm-g++ \ -prefix ../qt-arm-4.7.3 -little-endian -no-webkit -no-qt3support \ -no-cups -no-largefile -optimized-qmake -no-openssl -nomake tools \ -no-freetype -opensource -confirm-license -qt-mouse-tslib
Qt Installation Guide
6 / 10
If you have a single-core host, just use "make". Not recommended to use more than 2 cores as may cause build problems.
Now you should be able to just type arm-linux-qmake anywhere and have it run the correct cross compiled binary because the ..../4.3.3/bin directory is already in your path. Start by removing any existing Qt files from your RFS:
Copy the contents of the ~/cmpt433/private/qt-arm-4.7.3/lib directory to your root file system:
> cp -r ~/cmpt433/private/qt-arm-4.7.3/lib/ \ ~/cmpt433/private/fs-qt4.7.3/opt/qtlibs
Otherwise, your root-file system will be greater than 64Meg and won't fit in memory to download, or fit into flash on the board. To save more space, delete the folder .../fs-qt4.7.3/root/Documents
> rm -rf ~/cmpt433/private/fs-qt4.7.3/root/Documents
10. Trouble shooting: Problem configuring? Make sure tslib is compiled and installed correctly. See what is going on by turning on all warnings by adding a -v to the ./configure command's parameter list. This should help you identify what is going wrong. Ensure you have copied the tslib files into ~/cmpt433/private/tslib/lib/:
> cp -r ~/cmpt433/private/tslib/lib/* \ ~/cmpt433/private/qt-arm-4.7.3/lib/
While downloading the root file system image using UBoot, it may reboot before the
7 / 10 Generated Nov 7, 2011
Qt Installation Guide
download ("####...") is complete. Check the size of the file system image you are trying to download. It should be less than about 60 megs. If it's too big, delete unused Qt libraries or fonts from your root-file system on the host.
2. Clean the build to remove previous build files: 3. Configure Qt for the host:
> ./configure
6. Set paths (add to ~/.profile): 7. Log-out and re-log 8. Test that Qt is installed and in the path by running:
> qmake -v
9. Trouble shooting: If you get the error: "Basic XLib funcionality test failed"
> sudo apt-get build-dep qt4-qmake
Qt Installation Guide
8 / 10
5. Cross-Compiling Qt Application
1. Create a directory for your Qt applications:
> mkdir ~/cmpt433/private/myApps/qt > mkdir ~/cmpt433/private/myApps/qt/qthello
2. Create a directory for a "Hello Qt World" app: 3. Copy the following code into a file qthello.cpp in the above directory: <REVISIT:- CODE HERE> 4. Run "qmake -project" to generate the Qt project file (qthello.pro) > cd ~/cmpt433/private/myApps/qt/qthello
> arm-linux-qmake -project
6. Make the hello Qt world application: Your executable, qthello, should now be built.
You should see a (quite small) application. Close it using the touch-screen an the X button.
9. When your application exits, it may say it caused a "Segmentation fault" or "Illegal instruction". It is unknown what causes this, but it *seems* to be OK with these errors. 10. Trouble shooting: While building, if you get the error "undefined reference to `ts_read_raw'" then you need to copy the tslib/lib contents into the /qt-arm-4.7.3/lib folder. If your Qt application runs, but the touch-screen won't work then: Ensure the newly built Qt libraries are copied to the RFS and downloaded to the board. Ensure that the tslib/lib files are correctly installed in the root file system. Double check the tslib section and ensure that the Qt runtime environment variables are correctly setup. Check on the target using:
> printenv
Qt Installation Guide
4. Compile:
5. Run application: 6. To switch between build targets (build native for host, or cross-compile for target), use: HOST:
> make -f Makefile.x86 -B
7. When you add more files to the project, you'll have: Regenerate/edit the .pro file:
> qmake -project
Look for the line "Machine:" Built for host (Intel x86):
Machine: Intel 80386 ARM
Qt Installation Guide
10 / 10