In linux, configure QT-general Linux technology-Linux programming and kernel information. For more information, see. 1. Download the Qt source package to the local machine and decompress it.
# Tar zxvf qt-x11-opensource-src-4.3.2.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:
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-opensource-src-4.3.2.tar.gz can be, because in/root /. the bash_profile file has defined the environment variable QTDIR =/usr/local/qt-x11-opensource-src-4.3.2.tar.gz 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!
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
# 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.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!
If an error occurs during compilation: QMAKESPEC has not been set, so configuration cannot be deduced.
Error processing project file: XXXXX. pro
The QMAKESPEC variable is not set. Add a line in/root/. bash_profile:
Export QMAKESPEC =/usr/local/qt-x11-opensource-src-4.3.2/mkspecs/linux-g ++ (path to linux-g ++ ).
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