First, download the QT source package to this machine, and then unzip
#tar zxvf qt-x11-opensource-src-4.3.2.tar.gz-c/usr/local//Unzip the qt-x11-opensource-src-4.2.3.tar.gz source package to/usr/ Local directory (recommended decompression to/usr/local directory)
Second, enter the user home directory of the. bash_profile file to set the QT environment variable, here we take the root user example.
#vi/root/.bash_profile//Open root user. bash_profile file
Set the environment variable in the root user. bash_profile file, and add the following in this file:
qtdir=/usr/local/qt-x11-opensource-src-4.3.2
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 above information, press ESC, "shife+:" Key back to the VI Editor command line status, enter wq! (Force save exit)
Third, after the environment variable is added, the environment variable takes effect immediately: #source/root/.bash_profile
Iv. entering the QT decompression directory
#cd $QTDIR or #cd/usr/local/qt-x11-opensource-src-4.3.2, because environment variables are already defined in the/root/.bash_profile file qtdir=/usr/local/ qt-x11-opensource-src-4.3.2 and Export Qtdir.
Use the Configure tool to build the QT library and the tools it provides: the./configure (./configure--help Configuration selection list. Example:-thread option to create a multi-thoroughbred version of this library. )
Six, the last step to enter the long QT installation compile time, something to go out to do it, install the compilation time of about two hours. Compile command: Make
QT installation process is like this, I wish you to install QT success!
First we go to the Linux GUI, open a control terminal (right click on the desktop space, select "New Control Terminal" in the pop-up menu.) ), create a new. cpp file inside the control terminal and write the program as follows:
#vi HelloWorld.cpp//Create a HelloWorld.cpp file
#include
#include
int main (int argc,char *argv[])
{
Qapplication app (ARGC,ARGV);
Qlabel *label=new Qlabel ("Hello world!!!", 0);
App.setmainwidget (label);
Label->show ();
return App.exec ();
}
After writing the above code, save the Exit (Wq) VI Editor.
#qmake-project//Compile the. cpp file into a. pro file
#qmake Helloworld.pro//Automatically create makefile files through. Pro Files
#make//compile, generate HelloWorld execution file
#./helloworld//Run HelloWorld file
The Program normal Operation dialog box displays "HelloWorld!!!" to prove the QT installation success!
If there is an error at compile time: Qmakespec have not been set, so the configuration cannot be deduced.
Error Processing Project File:XXXXX.pro
Is the QMAKESPEC variable is not set, add a line in the/root/.bash_profile:
Export qmakespec=/usr/local/qt-x11-opensource-src-4.3.2/mkspecs/linux-g++ (that is, the path to linux-g++).
Http://blog.chinaunix.net/uid-25749806-id-300040.html
Configure QT under Linux (very full steps, configuration Qmakespec)