Install Qt in Linux

Source: Internet
Author: User
Tags qt designer

Some time ago, I simply learned about the Linux-based QT programming software. The most memorable thing for me is that the installation of QT compilation took two hours. The following describes how to install QT:

1. Download the QT source package to the local machine and decompress it.

: Http://download.qt.nokia.com/qt/source/
# Tar zxvf qt-x11-free-3.2.1.tar.gz-C/usr/local // extract the qt-x11-opensource-src-4.2.3.tar.gz source code package to the/usr/local directory (we recommend that you extract it to the/usr/local directory)

2. Enter the. bash_profile file in the user's home directory to set the QT environment variable. Here we use the root user as an example.
# Vi/root/. bash_profile // open the root user. bash_profile File
Set the environment variables in the root user. bash_profile file, and add the following content to the file:
Qtdir =/usr/local/qt-x11-opensource-src-4.3.0
Path = $ qtdir/bin: $ path
Manpath = $ qtdir/doc/MAN: $ manpath
LD_LIBRARY_PATH = $ qtdir/lib: $ LD_LIBRARY_PATH
Export qtdir path manpathld_library_path
After adding the preceding information, Press ESC and press the "shife +:" key combination to return to the command line status of the VI editor and enter WQ! (Force save and Exit)

3. Make the environment variable take effect immediately after adding the environment variable: # source/root/. bash_profile

4. Enter the QT decompressed directory
# Cd $ qtdir or # cd/usr/local/qt-x11-free-3.2.1 can be, because in/root /. the bash_profile file has defined the environment variable qtdir =/usr/local/qt-x11-free-3.2.1 and export qtdir.

5. Use the configure tool to build the QT Library and the tool it provides:./configure (./configure -- help to configure the selected list. For example, the-thread option is used to create a multi-vendor version of the library .)

6. The last step is about to take a long time to install and compile QT. If you have something to do, it takes about two hours to install and compile. Compile command: Make
This is the installation process of QT. I wish you a successful installation of QT !! My installation environment is Red Hat Linux 9.

First, go to the Linux graphical interface and open a control terminal (right-click the desktop space and select "new control terminal" in the pop-up menu ".), Create a. cpp file in the control terminal and write the program as follows:
# Vi helloworld. cpp // create a helloworld. cpp File
# Include <qapplication. h>
# Include <qlabel. h>
Int main (INT argc, char * argv [])
{
Qlabel * label = new qlabel ("Hello world !!! ", 0 );
Qapplication app (argc, argv );
App. setmainwidget (Label );
Label-> show ();
Return app.exe C ();
}
After writing the above Code, save and exit the (WQ) VI editor.
# Qmake-Project // compile the. cpp file into a. Pro File
# Qmake helloworld. Pro // use the. Pro file to automatically create a makefile
# Make // compile and generate the helloworld execution File
#./Helloworld // run the helloworld File
The "helloworld!" dialog box appears !!!", Verify that QT is successfully installed !!

Qt 3.0 simple installation and User Guide

Suppose you have downloaded the source code package of QT 3.0 and decompressed it to the/usr/local/Qt directory. Then, follow the steps below to install the QT library on your computer. This method is compiled and installed in Red Hat Linux 7.1.

1. Set the environment variable first; otherwise, QT cannot be compiled.
Edit the/etc/profile file and enter:

Qtdir = "/usr/local/Qt"
Path = "$ qtdir/bin: $ path"
LD_LIBRARY_PATH = "$ LD_LIBRARY_PATH"
Qmakespec = "Linux-G ++"
Export qtidr path LD_LIBRARY_PATH qmakespec

For the qmakespec environment variables, refer to the name in the $ qtdir/mkspec directory. You can set them according to your system compiling environment.
For example, if you use Microsoft Visual Studio to compile a program, you must set the following environment variables:
Qmakespec = win32-msvc"
Set it like this in Linux:
Qmakespec = "Linux-G ++"

2. Compile QT.

CD/usr/local/QT
./Configure
Make
Meide sleeps for N hours...
Qmake

3. Use QT 3.0 to compile the program.

Assume that you have used QT designer to make a form and have written the response code for related events, in QT designer, select file | new and select "C ++ main-file (main. CPP), and then save.
Switch to the command line mode and enter:

Qmake
Make

During the second compilation, you do not need to enter qmake any more, because make will work for you.

This article from the Linux community website (www.linuxidc.com) original link: http://www.linuxidc.com/Linux/2009-07/20843.htm

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.