Cross-compiled ARM Qt (qt-everywhere-opensource-src-4.7.3)

Source: Internet
Author: User

Due to the actual project requirements, Qt needs to be compiled into the LINUX-ARM version, the following is the entire operation process, the program written using Qt has been run on the actual development board, posted here, I hope I can help my friends in need.


Preparations:
Linux Kernel version:
Linux 2.6.35-22-generic # 33-Ubuntu
 
Cross-compilation tool:
Arm-none-linux-gnueabi 4.4.1
 
Qt installation package:
Qt-everywhere-opensource-src-4.7.3.tar.gz

Install
1. Install the cross-compilation tool
1. The cross-compilation tool used by the local machine is: arm-none-linux-gnueabi.

2. Add the path of the Cross-compilation tool to the corresponding environment variables:
Export PATH =/usr/CodeSourcery/Sourcery_G ++ _ Lite/bin/: $ PATH

3. Run the following command to check whether the arm-none-linux-gnueabi compilation tool has been installed successfully.
A. Run the following command: arm-none-linux-gnueabi-g ++-v.
B. Run arm-none-linux-gnueabi-gcc-v.
If the corresponding version information is correctly printed in the preceding two steps, it indicates that the arm-none-linux-gnueabi compilation tool
Installed successfully!

Ii. Cross-compile arm QT
1. Download the Qt source package qt-everywhere-opensource-src-4.7.3.tar.gz;
 
2. decompress the Qt source code package.
Tar-xvfz qt-everywhere-opensource-src-4.7.3.tar.gz
 
3. Modify the file:/usr/local/qt-4.7.3-linux-arm/mkspecs/qws/linux-arm-g ++/qmake. conf

# Set the cross-compilation tool chain:
# The Cross-compilation tool used in this project is arm-none-linux-gnueabi-g ++.
#
QMAKE_CC = arm-none-linux-gnueabi-gcc
QMAKE_CXX = arm-none-linux-gnueabi-g ++
Qmake_link = arm-None-Linux-gnueabi-G ++
Qmake_link_shlib = arm-None-Linux-gnueabi-G ++

Qmake_ar = arm-None-Linux-gnueabi-ar cqs
Qmake_objcopy = arm-None-Linux-gnueabi-objcopy
Qmake_strip = arm-None-Linux-gnueabi-strip

4. (modify the G ++. conf file if necessary)
Modify file:/usr/local/qt-4.7.3-linux-arm/mkspecs/common/g ++. conf
 
# Set the compilation flag using ARM advanced features:
#
Qmake_cflags_release + =-O2-March = armv7-a-mtune = cortex-a9-mfloat-Abi = softfp
 
5. Configure Qt compilation options

Enter the Qt decompression directory and execute the following command:
. /Configure-prefix/usr/local/qt-4.7.3-linux-arm-install-embedded arm-host-little-endian-no-cups-no-3dnow-nomake examples-nomake demos-nomake docs-xplatform/qws/linux -arm-g ++

6. Execute the make command;
This step generally requires 2 ~ 3 hours
 
7. Execute the make install command;

8. Modify user environment variables
Export ARMQTDIR =/usr/local/qt-4.7.3-linux-arm-install
Export PATH = $ ARMQTDIR/bin: $ PATH
Export MANPATH = $ ARMQTDIR/man: $ MANPATH
Export LD_LIBRARY_PATH = $ ARMQTDIR/lib: $ LD_LIBRARY_PATH

9. test whether the arm qt has been installed and configured successfully:
A. Execute: qmake-v
Print the following information:
Qmake version 2.01a
Using QT version 4.7.3 in/usr/local/qt-4.7.3-linux-arm-install/lib
B. Run: Which qmake
Print the following information:
/Usr/local/qt-4.7.3-linux-arm-install/bin/qmake
 
C. Compile a simple test program named hello. cpp. Enter the file directory and compile the project to see if the program can be correctly compiled.

Hello. cpp source code:
# Include <qapplication>
# Include <qdebug>
Int main (INT argc, char * argv [])
{
QDebug ("Hello, welcome to Qt world! ");
Return 0;
}

Perform the following operations in sequence:
@ 1. Run: qmake-project hello1.cpp
Generate hello1.pro project file
@ 2. Execute: qmake hello1.pro
Generate Makefile
@ 3. Execute: make
Generate the hello. o and hello files

If the following error occurs during step @ 2:
QMAKESPEC has not been set, so configuration cannot be deduced.
Error processing project file: hello1.pro
If the qmakespec variable is not set, run:
Export qmakespec =/usr/local/qt-4.7.3-linux-arm-install/mkspecs/qws/Linux-arm-G ++

If the above information can be correctly printed, it indicates that the arm version QT has been installed and configured successfully. The success is that your arm version QT has gone!

Tip:
In all the above processes, be sure to pay attention to the relevant path and environment variable configuration. In addition, modify the corresponding part according to your own path.


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.