From: Workshop.
Qt is a cross-platform C ++ application development framework that is widely used to develop GUI programs. With the software developed by Qt, the same code can be compiled and run on any supported platform without modifying the source code. It automatically displays the unique graphic interface style of the platform based on the platform.
Qt is widely used in embedded development. With Qt, you only need to write an application and UI once, and you can deploy it across different desktop and embedded operating systems without re-writing the source code, it saves both time and development costs. 0. compiling environment
Operating System: Debian wheezy 32-bit
Gcc version: 4.7.1
Arm-linux-gcc: 4.4.6 (for TQ210 EmbedSky Tech)
Development Board: TQ210 (days embedded)
LCD screen: 7-inch (800x480)
1. Install tslib
Why install tslib? The main purpose is to calibrate the touch screen and deshake functions, so that you can better use the touch screen or install it.
: Http://sourceforge.net/projects/tslib.berlios/files/
The tslib1.4 mentioned on the internet is actually tslib1.0.4. How can it become 1.4, sweat... This tool is relatively small. Just compile it after configuration.
?
123456 |
tar
-xvjf tslib-1.0. tar .bz2 cd
tslib-1.0 . /autogen .sh . /configure
--prefix= /opt/tslib-1 .0 --host=arm-linux ac_cv_func_malloc_0_nonnull= yes make make
install |
Prefix is behind the installation directory, customized by yourself, installed after modification/opt/tslib-1.0/etc/ts. conf, remove the # sign before module_raw input, and then copy the files in/opt/tslib-1.0 into the Development Board, for example, I put it in/usr/local. Configure the environment variables of the Development Board so that tslib can work properly.
?
12345 |
export
set TSLIB_FBDEVICE= /dev/fb0 export
set TSLIB_TSDEVICE= /dev/event4 export
set TSLIB_CONFFILE= /usr/local/etc/ts .conf export
set TSLIB_CALIBFILE= /etc/pointercal export
set TSLIB_PLUGINDIR= /usr/local/lib/ts |
Run ts_calibrate in/usr/local/bin for calibration. If the calibration succeeds, an interface is displayed, and you are asked to click the cross symbol to generate the/etc/pointercal file, this is the calibration configuration file for the touch screen.
Problems:
1. Error in autogen, prompt
./Autogen. sh: 4: autoreconf: not found
This is because automake is not installed in the system.
?
1 |
aptitude
install autoconf automake libtool |
2. An error occurred while making. The prompt is displayed.
In function 'open ',
Inlined from 'main' at ts_calibrate.c: 229: 11:
/Usr/include/bits/fcntl2.h: 51: 24: Error: Call to '_ open_missing_mode' declared with attribute error: open with o_creat in second argument needs 3 arguments
Make [2]: *** [ts_calibrate.o] Error 1
This is because the open function syntax does not comply with the latest gcc, and the third parameter of open is added to/tests/ts_calibrate.c:
?
12345 |
if
((calfile = getenv ( "TSLIB_CALIBFILE" )) != NULL) {
cal_fd = open (calfile, O_CREAT | O_RDWR, 0777); }
else {
cal_fd = open ( "/etc/pointercal" , O_CREAT | O_RDWR, 0777); } |
2. Install Qt4.8.3
For ease of development, we generally write a program on the PC end, simulate the program, debug the program, and then use arm-linux-gcc to compile the program into the arm version, and then copy it to the Development Board for running. Therefore, we must compile two sets of Qt library files: PC and arm.
2. 1. Install Qt for Linux/X11
Download Page: http://qt-project.org/downloads
Choose Qt libraries 4.8.3 for Linux/x11to go to qt-everywhere-opensource-src-4.8.3.tar.gz. This file is the same as Qt libraries 4.8.3 for embedded Linux. Different versions can be compiled based on different configurations, unzip, configure, and make.
?
12345 |
tar
-xvzf qt-everywhere-opensource-src-4.8.3. tar .gz cd
qt-everywhere-opensource-src-4.8.3 . /configure
-prefix /opt/qt-4 .8.3-x11 make make
install |
Because the library is large, it takes some time to compile it. After the compilation is complete, install. The installation directory after-prefix is modified as needed.
Error during compilation, prompt
G ++: Error: Unrecognized command line option '-fuse-LD = Gold'
This is a bug in QT: https://bugs.webkit.org/show_bug.cgi? Id = 89312
In a system with a gold linker installed, the-fuse-LD = gold option is added to the compilation script, but this option is not supported by GCC. The solution is to remove this option, find the file src/3 rdparty/WebKit/source/common. PRI, and shield qmake_lflags + =-fuse-LD = gold.
?
1 |
# QMAKE_LFLAGS+=-fuse-ld=gold |
2. Install Qt for embedded
The source code is the same. Just reconfigure it.
?
123 |
. /configure
-prefix /opt/qt-4 .8.3-arm -embedded arm -release -shared -fast -no-largefile -qt-sql-sqlite -qt3support -no-xmlpatterns -no-glib -no-phonon -no-mmx -no-3dnow -no-sse -no-sse2 -no-svg -webkit -qt-zlib -qt-libtiff -qt-libpng -qt-libjpeg - make
libs -nomake examples -nomake docs -nomake demo -no-nis -no-cups -iconv -no-dbus -openssl -xplatform qws /linux-arm-g ++ -little-endian -qt-freetype -depths 16,24,32 -qt-gfx-linuxfb -qt-gfx-transformed -qt-gfx-multiscreen -no-gfx-vnc -no-gfx-qvfb -qt-kbd-linuxinput -no-kbd-qvfb -armfpa -no-mouse-qvfb -qt-mouse-linuxtp -qt-mouse-tslib -DQT_QLOCALE_USES_FCVT -I /opt/tslib-1 .0 /include
-L /opt/tslib-1 .0 /lib make make
install |
The configuration option should be selected based on your own hardware, so that the compiled library file will be relatively small. After installation, copy the imports, Lib, mkspecs, and plugin folders in the directory to the/opt/Qt directory on the Development Board. The directory is just the same as that in the environment variables. Then configure the environment variables of the Development Board so that he can find QT.
?
1234567891011 |
export
set QTDIR= /opt/Qt export
set QPEDIR= /opt/Qt export
set LD_LIBRARY_PATH=$QTDIR /lib : /usr/local/lib :$LD_LIBRARY_PATH export
set QT_QWS_FONTDIR=$QTDIR /lib/fonts/ export
set QWS_SIZE=800x480 export
set QWS_DISPLAY= "LinuxFb:mmWidth80:mmHeight120:0" export
set QWS_DISPLAY= "LinuxFB:/dev/fb0" export
set QT_PLUGIN_PATH=$QTDIR /plugins/ export
set QWS_KEYBOARD= "TTY:/dev/tty1" export
set QWS_MOUSE_PROTO= "TSLIB:/dev/event4" export
PATH=$QTDIR /bin :$PATH |
3. Install Qt Creator
Qt creator is an IDE for developing QT programs. Of course, you can also use command lines for development. Choose http://qt-project.org/downloadsand select QT creator 2.6.0 for Linux/X11 32-bit. If it is a 64-bit system, select the 64-bit version. Download the qt-creator-linux-x86-opensource-2.6.0.bin and run the installation.
?
1 |
. /qt-creator-linux-x86-opensource-2 .6.0.bin |
Configure qmake after installation, go to the tool> Options> build and run> QT version, add qmake installed X11 and arm versions, and add qmake in their respective bin folders, the result is as follows.
Add a cross-compilation tool chain gcce.
OK. Now the configuration is complete. Let's test it.
4. Hello Qt
Create a file or project-> qt gui application-> next, select embedded Linux, and remove X11 in details (X11 is on PC), as shown in.
Keep the default settings. After that, open the interface file, add a hello QT label, Build-> Run.
In the lower left corner, switch to the embedded Linux version, build, copy the compiled hello_qt file to the Development Board, and run./hello_qt with an error:
Qwssocket: connecttolocalfile cocould not connect: Connection refused
No QT for Embedded Linux Server appears to be running.
If you want to run this program as a server,
Add the "-qws" command-line option.
Follow the prompts to add-qws and run it again.
?
Succeeded. Check that the original QT operation requires a QT service process. After adding-qws, the current QT program is treated as the server.
So far, all QT transplantation has been completed.