Chapter 1 build the Qt development environment, Chapter 1 build the qt Development
Chapter 1 build a Qt Development Environment
1.Ftp://ftp.qt-project.org/Download the source code package of Qt. I downloadedQt-everywhere-opensource-src-4.8.1.tar.gz. Qt Creator downloadsQt-creator-linux-x86-opensource-2.5.2.bin.
2. Go to the terminal and runSudo apt-get install build-essentialInstall g ++ and make. Or directlySudo apt-get install g ++.
3.enter the directory where qt-everywhere-opensource-src-4.8.1.tar.gz is located and useTar xvzf qt-everywhere-opensource-src-4.8.1.tar.gzCommand to decompress the downloaded Qt source package.
4. ExecuteSudo apt-get install libX11-dev libXext-dev libXtst-devCommand to install the three software. Ubuntu is not installed by default during installation. (Perform this step)
5. Enter the decompressed directory and run it on the terminal../ConfigureAnd then select the installation type. Input O to open source. Enter yes to accept the GPL protocol. Configure to generate the makefile file.
6. After configure is complete, runMake, Waiting to compile Qt.
7. After make is complete, runSudo make installInstall Qt, which is installed in the/usr/local/Trolltech/Qt-4.8.1 folder by default.
8. Configure environment variables. Use the terminal to add the directory "/usr/local/Trolltech/Qt-4.8.1/bin" to the PATH:
Export PATH =/usr/local/Trolltech/Qt-4.8.1/bin: $ PATH
Or
ExportPATH = $ PATH:/usr/local/Trolltech/Qt-4.8.1/bin
This method is applicable to temporary modification and becomes invalid after logon. You can use the following method to permanently modify the settings:
Sudo vi/etc/environment
Add:/Usr/local/Trolltech/Qt-4.8.1/bin, Save and restart the system.
9. Qt installation is complete. Run the qmake-version command on the terminal. The corresponding information is displayed, indicating that the installation is successful.
Write a program to test and create a folder project.
Open the terminal to create a main. cpp file, and vi to open the file, enter the following content:
# Include <QtGui>
Int main (int argc, char * argv [])
{
QApplication app (argc, argv );
QWidget * widget = new QWidget (0 );
Widget-> show ();
Return app.exe c ();
}
After writing the above Code, save and exit (: wq) vi editor.
Enter the project folder. Run the following commands in sequence:
Qmake-project
Qmake main. pro
Make
./Project
If the program is normal, you will see the widget box.
10. Install Qt Creator. Go to the directory where the qt-creator-linux-x86-opensource-2.5.2.bin is located and execute at the terminalChmod u + xQt-creator-linux-x86-opensource-2.5.2.binAnd then execute./Qt-creator-linux-x86-opensource-2.5.2.binInstall Windows. The installation process is similar to that of windows.