The entire process of compiling and installing and configuring Qt in Linux

Source: Internet
Author: User

The entire process of compiling and installing and configuring Qt in Linux

Recently, we are preparing to develop the Nokia Symbian and maemo touch screen. Considering the cross-platform portability of the program, QT development is the final choice. Relatively speaking, there are not many documents about Qt in China. The author summarized the entire process of compiling and installing and configuring Qt in Linux. I just hope it will be convenient for more friends!

1.Obtain source code

SRC Official Website: ftp://ftp.qt.nokia.com/qt/source/
Qt-x11-opensource-src-4.5.3.tar.gz released in October 1, 2009, size 122 MB.

2.Extract

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

3.Generate makefile

./Configure
At this time, he will ask you: "Which edition of QT do you want to use ?"
Then you can select two types:
Type 'C' if you want to use the specified cial edition.
Type 'O' if you want to use the open source edition.
The first is the commercial version, and the second is the free version.
Select 'O' (QT/Embedded Free Edition is the embedded version provided by QT to develop free software ).
At this time, the license page appears.
Select Yes to accept the license agreement.
Start generating makefile. This takes about 5-10 minutes.

4.Qt Compilation

Gmake
This process takes about two hours.

5.Qt Installation

Run gmake install
Default installation to/usr/local/trolltech/Qt-4.5.3
About 5-10 minutes. The installation is complete.
Run/usr/local/trolltech/Qt-4.5.3/bin/designer and see QT start, that is, QT is installed.

6.Set Environment Variables

I. Modify user environment variables first

VI/home/defonds/. bashrc

Add the following information at the end

Export qtdir =/usr/local/trolltech/Qt-4.5.3
Export Path = $ qtdir/bin: $ path
Export manpath = $ qtdir/MAN: $ manpath
Export LD_LIBRARY_PATH = $ qtdir/lib: $ LD_LIBRARY_PATH

II. Modify all user environment variables

VI/etc/profile
Add the following information at the end
Export qtdir =/usr/local/trolltech/Qt-4.5.3
Export Path = $ qtdir/bin: $ path
Export manpath = $ qtdir/MAN: $ manpath
Export LD_LIBRARY_PATH = $ qtdir/lib: $ LD_LIBRARY_PATH

3. Test

Restart a terminal and enter the following command:

Qmake-V

Output result:

Qmake version 2.01a
Using QT version 4.5.3 in/usr/local/trolltech/Qt-4.5.3/lib
Enter the following command:

Which qmake

Output result:

// Usr/local/trolltech/Qt-4.5.3/bin/qmake
It proves that the QT environment variable has been configured successfully.

Editor's Note
:

When Linux is started, it first reads the user's environment variable, that is, the setting of/home/defonds/. bashrc. Read all user environment variables, that is, the configuration in/etc/profile.

Start QT

Write a simple QT program and use the installed QT compilation to test its working effect.
Create a new file named hello. cpp with the following content:
# Include <qapplication> <br/> # include <qlabel> <br/> int main (INT argc, char * argv []) <br/>{< br/> qapplication app (argc, argv); <br/> qlabel * label = new qlabel ("Hello QT! "); <Br/> label-> show (); <br/> return app.exe C (); <br/>}
Save hello. cpp. The compilation process is as follows:
In the directory where hello. cpp is located, run the command
Qmake-Project
Hello. cpp: The hello. Pro file is generated in the same directory. It is a platform-independent project file.
In the directory where hello. cpp is located, run the command
Qmake hello. Pro
Makefile files are generated in the same directory (makefile is the configuration file that guides the compiler to compile the source code. Enter the make command in the directory (nmake is in Win32 and vc6 environments) to complete the compilation ).
In the directory where hello. cpp is located, run the command
Make
The Hello and hello. O files in the same directory are compiled and generated. Hello is the executable file generated by QT compilation in the current Linux system. Double-click to run Hello, "Hello QT! "The text box pops up. OK! This step proves that QT can work on your computer. What are you waiting for? Start your wonderful and pleasant QT development journey!

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.