Self-starting QT Program

Source: Internet
Author: User

 

Qt download: http://qt.nokia.com/downloads

Qt SDK for Open Source C ++ development on Linux/X11 32-bit is a pc sdk, including qtcreator.

Qt for Open Source C ++ development on Embedded Linux is an embedded development library.

 

Only the installation of ARM is described here.

1. Compile the tslib Library

Tslib1.41 provided by day embed download: http://download.csdn.net/source/2661205

Make sure that the configuration is correct. Otherwise, the touch screen may only move the mouse and cannot be clicked.

View plaincopy
To clipboardprint?
  1. . /Configure -- Host = arm-Linux-disable-hp3600 -- disable-arctic2 -- disable-mk712 -- disable-collie -- disable-corgi -- disable-ucb1x00 -- disable-linear-h2200 -- With-GNU-LD -- prefix =/opt/QT/ tslib ac_cv_func_malloc_0_nonnull = Yes

. /Configure -- Host = arm-Linux-disable-hp3600 -- disable-arctic2 -- disable-mk712 -- disable-collie -- disable-corgi -- disable-ucb1x00 -- disable-linear-h2200 -- With-GNU-LD -- prefix =/opt/QT/ tslib ac_cv_func_malloc_0_nonnull = Yes

Make and make install after configuration. Install tslib in/opt/QT/tslib.

 

2: Compile QT-embedded-arm and install it in/opt/QT/qt-embedded-4.6.3-arm. Create a config. Sh file to save the configuration and run./config. Sh. The content is as follows:

View plaincopy
To clipboardprint?
  1. . /Configure-Prefix/opt/QT/qt-embedded-4.6.3-arm-release-opensource-shared-fast-no-largefile-QT-SQL-SQLite-no-qt3support-no-xmlpatterns-no-MMX-no-3dnow -No-SSE-no-sse2-no-SVG-no-WebKit-QT-zlib-QT-GIF-QT-LibTIFF-QT-libpng-QT-libjpeg-make libs-nomake examples -nomake docs-nomake demo-no-Nis-no-cups-no-iconv-no-signature-no-OpenSSL-xplatform qws/Linux-arm-G ++-Embedded ARM -Little-Endian-QT-FreeType-Depths 16,18-QT-GFX-linuxfb-QT-GFX-transformed-QT-GFX-multiscreen-no-GFX-VNC-no-GFX- qvfb-QT-KBD-linuxinput-no-glib-QT-mouse-tslib-I/opt/QT/tslib/include-L/opt/QT/tslib/lib

. /Configure-Prefix/opt/QT/qt-embedded-4.6.3-arm-release-opensource-shared-fast-no-largefile-QT-SQL-SQLite-no-qt3support-no-xmlpatterns-no-MMX-no-3dnow -No-SSE-no-sse2-no-SVG-no-WebKit-QT-zlib-QT-GIF-QT-LibTIFF-QT-libpng-QT-libjpeg-make libs-nomake examples -nomake docs-nomake demo-no-Nis-no-cups-no-iconv-no-signature-no-OpenSSL-xplatform qws/Linux-arm-G ++-Embedded ARM -Little-Endian-QT-FreeType-Depths 16,18-QT-GFX-linuxfb-QT-GFX-transformed-QT-GFX-multiscreen-no-GFX-VNC-no-GFX- qvfb-QT-KBD-linuxinput-no-glib-QT-mouse-tslib-I/opt/QT/tslib/include-L/opt/QT/tslib/lib

However, if this is the case, the segmentation fault error will occur after porting to the Development Board (although the QT program can be started twice). This error is actually caused by the linuxfb problem in the graphic buffer zone, you can modify the qt-everywhere-opensource-src-4.6.3/src/GUI/Embedded/qscreenlinuxfb_qws.cpp source code:

About 424 rows:

View plaincopy
To clipboardprint?
  1. /* // Embedsky_del start 20091208
  2. Canaccel = useoffscreen ();
  3. If (canaccel)
  4. Setupoffscreen ();
  5. * // Embedsky_del end 20091208
  6. Canaccel = false;

/* // Embedsky_del start 20091208 <br/> canaccel = useoffscreen (); <br/> If (canaccel) <br/> setupoffscreen (); <br/> * // embedsky_del end 20091208 <br/> canaccel = false;

About 726 rows:

View plaincopy
To clipboardprint?
  1. /* // Embedsky_del start 20091208
  2. If (canaccel ){
  3. * Entryp = 0;
  4. * Lowest = mapsize;
  5. Insert_entry (* entryp, * Lowest, * Lowest); // dummy entry to mark start
  6. }
  7. * // Embedsky_del end 20091208
  8. Canaccel = false;

/* // Embedsky_del start 20091208 <br/> If (canaccel) {<br/> * entryp = 0; <br/> * Lowest = mapsize; <br/> insert_entry (* entryp, * Lowest, * Lowest ); // dummy entry to mark start <br/>}< br/> * // embedsky_del end 20091208 <br/> canaccel = false; <br/>

In addition, if some unnecessary or unsupported hardware options are not removed in./configure, segmentation fault may occur. For the S3C2440 Development Board, refer to the above configuration.

After modification, make and make install

 

3: Copy all the so files under tslib/lib to the qt-embedded-4.6.3-arm/lib (if you do not copy it, some libraries cannot be found when compiling the program in step 1 ). The Ts and pkgconfig folders can be copied.

 

4: copy the lib and plugins folders under the qt-embedded-4.6.3-arm to/opt/qt4.6.3 under the Development Board file system. Then, delete files other than. So and retain only the required font.

5: copy the tslib/etc/ts. conf file to the/etc File System of the Development Board, and remove the # number before the second line.

View plaincopy
To clipboardprint?
  1. # Uncomment if you wish to use the Linux input layer event Interface
  2. Module_raw Input

# Uncomment if you wish to use the Linux input layer event interface <br/> module_raw Input

6. Load the QT runtime environment variable and modify the/etc/profile file of the Development file system.

View plaincopy
To clipboardprint?
  1. # Ash Profile
  2. # VIM: syntax = sh
  3. # No core files by default
  4. # Ulimit-s-c 0>/dev/null 2> & 1
  5. ############# QT start #################
  6. Export set qtdir =/opt/qt4.6.3
  7. Export set qws_display = "linuxfb:/dev/fb0"
  8. Export set qws_display = "linuxfb: mmwidth130: mmheight100: 0"
  9. Export set qws_keyboard = "TTY:/dev/tty1"
  10. If [-F/sys/class/input/input0/uevent]; then
  11. Export set tslib_tsdevice =/dev/event0
  12. Export set tslib_calibfile =/etc/pointercal
  13. Export set tslib_conffile =/etc/ts. conf
  14. Export set tslib_plugindir = $ qtdir/lib/TS
  15. Export set qws_mouse_proto = "tslib:/dev/event0"
  16. Fi
  17. Export set qt_qws_fontdir = $ qtdir/lib/fonts/
  18. Export set Path = $ qtdir/bin: $ path
  19. Export set LD_LIBRARY_PATH = $ qtdir/lib: $ qtdir/plugins/imageformats: $ LD_LIBRARY_PATH
  20. ############## QT end #####################
  21. User = "'id-UN '"
  22. LOGNAME = $ user
  23. PS1 = '[/u @/h/W] #'
  24. Path = $ path
  25. Hostname = '/bin/hostname'
  26. Export user LOGNAME PS1 path

# Ash profile <br/> # VIM: syntax = sh <br/> # No core files by default <br/> # ulimit-s-c 0>/dev/null 2> & 1 <br/> ### ########### QT start ################# <br/> export set qtdir =/OPT /qt4.6.3 <br/> export set qws_display = "linuxfb: /dev/fb0 "<br/> export set qws_display =" linuxfb: mmwidth130: mmheight100: 0 "<br/> export set qws_keyboard =" TTY: /dev/tty1 "<br/> If [-F/sys/class/input/input0/uevent]; then <br/> export set tslib_tsdevice =/dev/event0 <br/> export set tslib_calibfile =/etc/pointercal <br/> export set tslib_conffile =/etc/ts. conf <br/> export set tslib_plugindir = $ qtdir/lib/TS <br/> export set qws_mouse_proto = "tslib: /dev/event0 "<br/> fi <br/> export set qt_qws_fontdir = $ qtdir/lib/fonts/<br/> export set Path = $ qtdir/bin: $ PATH <br/> export set LD_LIBRARY_PATH = $ qtdir/lib: $ qtdir/plugins/imageformats: $ LD_LIBRARY_PATH <br/> ############## QT end ################## ### <br/> User = "'id-UN'" <br/> LOGNAME = $ user <br/> ps1 = '[/u @/h/W] # '<br/> Path = $ PATH <br/> hostname ='/bin/hostname' <br/> Export user LOGNAME PS1 path

Now you can run the QT program on the Development Board.

7. Start the QT Program

Since the boot program is in/etc/init. d/RC is loaded. However, to run the QT program, you must first set the environment variable for running QT. The/etc/profile is in/etc/init. d/RC is loaded, so to start the program, you must first set the environment. Here we can use a script to set the environment and start the program. Create a new file qt4, put it in bin or sbin, and set its permissions to executable. The content is as follows: (Here we start a qtbeep program compiled by myself)

View plaincopy
To clipboardprint?
  1. #! /Bin/sh
  2. Echo start qt4.6.3>/dev/tq2440_serial0
  3. Export set qtdir =/opt/qt4.6.3
  4. Export set qws_display = "linuxfb:/dev/fb0"
  5. Export set qws_display = "linuxfb: mmwidth130: mmheight100: 0"
  6. Export set qws_keyboard = "TTY:/dev/tty1"
  7. If [-F/sys/class/input/input0/uevent]; then
  8. Export set tslib_tsdevice =/dev/event0
  9. Export set tslib_calibfile =/etc/pointercal
  10. Export set tslib_conffile =/etc/ts. conf
  11. Export set tslib_plugindir = $ qtdir/lib/TS
  12. Export set qws_mouse_proto = "tslib:/dev/event0"
  13. Fi
  14. Export set qt_qws_fontdir = $ qtdir/lib/fonts/
  15. Export set Path = $ qtdir/bin: $ path
  16. Export set LD_LIBRARY_PATH = $ qtdir/lib: $ qtdir/plugins/imageformats: $ LD_LIBRARY_PATH
  17. If [-F/etc/pointercal]; then
  18. $ Qtdir/bin/qtbeep-qws 1>/dev/null 2>/dev/null
  19. Else
  20. $ Qtdir/bin/ts_calibrate
  21. $ Qtdir/bin/qtbeep-qws 1>/dev/null 2>/dev/null
  22. Fi

#! /Bin/sh <br/> echo start qt4.6.3>/dev/tq2440_serial0 <br/> export set qtdir =/opt/qt4.6.3 <br/> export set qws_display = "linuxfb: /dev/fb0 "<br/> export set qws_display =" linuxfb: mmwidth130: mmheight100: 0 "<br/> export set qws_keyboard =" TTY: /dev/tty1 "<br/> If [-F/sys/class/input/input0/uevent]; then <br/> export set tslib_tsdevice =/dev/event0 <br/> export set tslib_calibfile =/etc/pointercal <br/> export set tslib_conffile =/etc/ts. conf <br/> export set tslib_plugindir = $ qtdir/lib/TS <br/> export set qws_mouse_proto = "tslib: /dev/event0 "<br/> fi <br/> export set qt_qws_fontdir = $ qtdir/lib/fonts/<br/> export set Path = $ qtdir/bin: $ PATH <br/> export set LD_LIBRARY_PATH = $ qtdir/lib: $ qtdir/plugins/imageformats: $ LD_LIBRARY_PATH <br/> If [-F/etc/pointercal]; then <br/> $ qtdir/bin/qtbeep-qws 1>/dev/null 2>/dev/null <br/> else <br/> $ qtdir/bin/ts_calibrate <br/> $ qtdir/bin/qtbeep-qws 1>/dev/null 2>/dev/null <br/> fi

In this way, we can directly add qt4 & to/etc/init. d/RCS.

(Note: This environment variable only affects the programs started in qt4. The environment variable after entering the system depends on/etc/profile)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.