Detailed process of building an embedded QT Environment

Source: Internet
Author: User
I have been searching for information on the embedded qt4 development environment for a long time. This is the most complete introduction I have seen. Thank you for sharing it! Original please connect: http://blog.chinaunix.net/space.php? Uid = 22915173 & Do = Blog & id = 68367

I. PC environment:

Vmware6.5;

The operating system is ubuntu9.10;

GCC version: 4.4.1;

The cross tool chain is version 4.1.1.

Ii. Install the cross tool chain:

Qt4 is best to use the GCC 4 tool chain. Here we provide the 4.1.1 version of the Cross tool chain, the tool chain package is: 4.1.20.softfloat_withlib.tar.bz2.

Decompress the package to the/opt/crosstool directory, and add a 4.1.1 directory to the/opt/crosstool directory. This is the cross tool chain of version 4.1.1.

Before using the cross tool chain of version 4.1.1, remember to set the PATH environment variable.

Export Path =/opt/crosstool/4.1.1/bin: $ path

 

Iii. Build the qt4 development environment in Ubuntu:

Develop qt4 applicationsProgramInstall the qt4 library, header file, and QT development tool. The general QT development environment includes two parts:

1. qt4 library files and header files;

2. qt4 development tools such as qmake, UIC, and MOC.

The following describes how to build the qt4 development environment in Ubuntu. There are generally three methods to build the qt4 development environment based on the Ubuntu platform:

(1) Use apt-Get install XXX to install the qt4 development tool from the Ubuntu source server:

Such as: APT-Get install libqt4-dev.

The qt4 Development Library and tool provided on the Ubuntu source server can search for the qt4 library and development tool on the new software manager and select install.

(2) Use the SDK for installation:

Qt provides the SDK installation package after version 4.5, you can download the SDK installation package from the ftp://ftp.qt.nokia.com/qtsdk/, the SDK installation package includes qt4 development of the dynamic library, header files and development tools. It also provides an integrated development environment for qtcreatr. qtcreator is an image-based Development Environment Integrating development and debugging.

Such as: qt-sdk-linux-x86-opensource-2009.04.1.bin

Run the preceding file on the terminal. The installation guide dialog box is displayed. Install the file as prompted in the dialog box.

(3) Compile and install from source code

Download the source code of qt-x11from "ftp://ftp.qt.nokia.com/qt/source/", as shown in

Download qt-x11-opensource-src-4.5.3.tar.gz;

On the Ubuntu terminal, decompress, configure, compile, and install the tool.

The procedure is as follows:

(1) decompress the source package:

CD/home/farsight

Tar zxvf qt-x11-opensource-src-4.5.3.tar.gz

(2) configure the source package:

CD qt-x11-opensource-desktop-4.5.3

./Configure

You can use-help to view the configuration options.

(3) Compile

Make

After configuration, the MAKEFILE file is generated and compiled using make.

(4) Installation

Make install

By default, the installation is installed in the/usr/local/trolltech/Qt-4.5.2/directory, where you can configure the installation directory by using the-prefix option.

Note that the qt4 provided by the source code package is the toolSource codeFor example, there is a qconfig tool under the source code tools, which is used to segment the configuration of the qt4 library. Using./configure for configuration is a rough configuration. You can use the qconfig tool to further segment the configuration of the QT library.

Generally, you can use a rough configuration. However, when cross-compiling the qt4 library, you can use the qconfig tool to further customize the qt4 library size. Qconfig is used to configure and compile QT-embedded below.

 

The qconfig tool can only be obtained from the QT source code. The qconfig tool is provided in the first two methods.

Therefore, we compile the configuration tool qconfig and copy it to the/usr/local/bin directory.

Make tools/qconfig

CP tools/qconfig/usr/local/bin/

When installing QT from source code, you need to set the following environment variables before using the QT-4.5.3:

Export qtdir =/usr/local/trolltech/Qt-4.5.3

Export Path = $ qtdir/bin: $ path

Export LD_LIBRARY_PATH = $ qtdir/lib: $ LD_LIBRARY_PATH

The preceding three methods are used to install the qt4 development environment in Ubuntu.

Iv. Cross-compile QT-embedded

(1) Cross-compile the qt4 Library

After obtaining the QT source package of the embedded Linux version, the general steps are decompression, configuration compilation, and installation. For example, the downloaded source code is qt-embedded-linux-opensource-src-4.5.3.tar.gz.

After extracting the source code, configure QT-embedded. The general configuration method is to use./configure in the source code directory for rough configuration. You can use the qconfig tool to slightly configure qt4.

After decompressing the QT-embedded source code, we can use the qconfig tool to configure qt4:

CD qt-embedded-linux-opensource-src-4.5.3

Qconfig src/corelib/global/qfeatures.txt

After the qconfig tool is started, a configuration interface is displayed, which allows you to select the QT configuration option.

After the configuration is complete, save the configuration as a qconfig-local.h file in the src/corelib/global/directory;

To make qt4 support touch screen, we add two macro definitions in the qconfig-local.h: # define qt_qws_ipaq

# Define qt_qws_ipaq_raw

These two macros indicate the use of built-in touch screen support in QT source code.

For example: My qconfig-local.h file content is as follows:

# Ifndef qt_h

# Endif

# Ifndef qt_dll

# Define qt_dll

# Endif

# Define qt_qws_ipaq

# Define qt_qws_ipaq_raw

# Define qt_no_qws_cursor

# Define qt_no_qws_mouse_auto

 

You can directly edit the production qconfig-local.h file in addition to getting the qconfig-local.h file using the qconfig tool. After the qconfig-local.h file is generated, configure the QT library using the./configure command;

The following are some configuration options for Qt-embedded:

./Configure-Prefix/usr/qt-4.5.3-debug-opensource-Embedded ARM-qconfig local-Depths 4, 8, 16-QT-mouse-linuxtp-qvfb

The configuration here is:

-Prefix specifies that the installation path is/usr/qt-4.5.3

-Debug indicates the debug version;

-Opensource indicates the Open Source version;

-Embedded ARM: specifies that the platform is arm;

-Qconfig local use the tiny profile qconfig-local.h

-Depths, 16, 32 specify the number of bits in the US Pixel

-QT-mouse-linuxtp specifies to use the touch screen specified by QT

Note that the platform is specified as arm, and the default cross tool chain starts with arm-Linux, while my tool chain starts with arm-Linux-GNU, therefore, modify mkspecs/qws/Linux-arm-G ++/qmake. in the conf file, replace the command starting with "arm-Linux-GNU-" with the command starting with "arm-Linux-GNU. CONF file, where the red part is changed:

#

# Qmake configuration for building with arm-Linux-G ++

#

Include (../common/g ++. conf)

Include (../common/Linux. conf)

Include (../common/qws. conf)

# Modifications to G ++. conf

Qmake_cc = arm-Linux-GNU-gcc

Qmake_cxx = arm-Linux-GNU-G ++

Qmake_link = arm-Linux-GNU-G ++

Qmake_link_shlib = arm-Linux-GNU-G ++

# Modifications to Linux. conf

Qmake_ar = arm-Linux-GNU-ar cqs

Qmake_objcopy = arm-Linux-GNU-objcopy

Qmake_strip = arm-Linux-GNU-strip

 

After the configuration is complete, you can compile and install it:

Make

Make install

The compilation takes a long time. After the compilation and installation, qt4 is installed in the/usr/qt-4.5.3 directory.

(2) Cross-Compilation of qt4 applications

To cross-compile a self-developed qt4 application, you need to configure the following environment variables:

Export qtdir =/usr/qt-4.5.3

Export qmakespec = qws/Linux-arm-G ++

Export Path = $ qtdir/bin: $ path

Export LD_LIBRARY_PATH = $ qtdir/lib: $ LD_LIBRARY_PATH

 

For example, if a QT program is developed on a PC and compiled and run successfully, you need to cross-compile the program. The step is to set the preceding environment variables first;

Then use qmake to regenerate the MAKEFILE file;

Then make is enough;

 

5. Deploy qt4 to the embedded root file system

Deploy qt4 to the root file system in two steps:

(1) copy the QT library and QT application to the root file system;

(2) configure the environment required when the QT application is running;

1. Copy the QT library and QT Application

The running of Self-compiled QT applications depends on the qt library. Therefore, when porting a QT application to the root file system, you need to port the QT Library to the root file system; s

For example, the build directory of the root file system is/opt/filesystem, and the installation directory of QT-embedded is/usr/qt-4.5.3. Use the following command to copy the QT Library

Mkdir/opt/filesystem/qt-4.5.3

Mkdir/opt/filesystem/qt-4.5.3/lib

CP-A/usr/qt-4.5.3/lib/* So */opt/filesystem/usr/qt-4.5.3/

CP-A/usr/qt-4.5.3/lib/fonts/opt/filesysgem/usr/qt-4.5.3/lib/

Copy the QT application to the root file system, for example, to the/opt/filesystem/usr/bin directory;

2. Configure the QT application running environment

When running the QT application, you must specify the following environment variables:

Display =: 0.0

Home =/tmp

Qtdir = "/usr/qt-4.5.3"

LD_LIBRARY_PATH = $ qtdir/lib: $ ld_library

Qws_mouse_proto = linuxtp:/dev/touchscreen/0

 

Display // specify the Display Device

Home // specify the Home Directory

Qtdir // specify the directory where QT is located

LD_LIBRARY_PATH // specify the path of the QT Library

Qws_mouse_proto // specify the device file used by the touch screen driver

 

Run the QT program:

When running the QT program on the ARM platform, if it is the first time to run the QT application, you need to add the-qws option to specify that the program is a server program, you can disable the-qws option for any subsequent startup.

For example:

CD/tmp

Hello-qws &

 

to deploy qt4, you need to understand the basic deployment process of the embedded root file system, and then deploy qt4 after the basic structure of the built root file system.

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.