My environment: CentOS 6.7 64-bit
1. Download qt:
QT version has a lot of comparison dishes, I hope the installation process simpler the better, feel the newer version will be good to install some, 5.4 version to update the/usr/lib64/libstdc++.so.6 file, 5.6 of words on the worry some
The address is as follows:
Http://download.qt.io/official_releases/qt/5.6/5.6.1/
Select and system corresponding, I chose the Qt-opensource-linux-x64-5.6.1.run
This. Run file contains both the SDK and the Ide:qtcreator
2. Install QT::
In the terminal into the downloaded qt installation file directory, general down to the main folder within the Downloads, so #cd ~/downloads
To change permissions before you can install: #chmod u+x Qt-opensource-linux-x64-5.6.1.run
And then you can #./qt-opensource-linux-x64-5.6.1.run install it.
The installation process will be more smooth, a little bit
3. Configure Environment variables
If you go into the Qtcreator directory, you can run Qtcreator, but every time it's a hassle, you can add it to the system environment variable
#vim/etc/profile behind the file is stored environment variables, if you do not get root permissions This file is read-only, so want to modify it to get permission first (I compare dishes are also lazy directly first #su, the back is not #sudo XXX)
Add in File
Export qtdir=/opt/qt5.6.1/tools/qtcreator
export path= $QTDIR/bin: $PATH
export manpath= $QTDIR/man: $MANPATH
Export ld_library_path= $QTDIR/lib: $LD _library_path
Where/opt/qt5.6.1 is the installation directory of my QT
#source/etc/profile to make the modified environment variable effective
Then #qtcreator can start Qtcreator.
If you want to develop with QT at the command line, you need to qmake this tool, you can add it to the environment variables in the same way as above
The path to my computer is/opt/qt5.6.1/5.6/gcc_64.
Next, try our first program HelloWorld
Select a directory to create our engineering folder HelloWorld and enter
#vim Helloworld.cpp
The edited content is as follows
#include <QApplication>
#include <QLabel>
int main (int argc,char *argv[])
{
Qapplication app (ARGC,ARGV);
Qlabel *label=new Qlabel ("helloworld!");
Label->show ();
return app.exec ();
}
After saving, you can start compiling.
#qmake-project
This step will find that there is a Helloworld.pro in the current folder, which is a common engineering document for each platform.
#qmake Helloworld.pro
There's more makefile in the folder.
#make
The executable file is generated smoothly ~
Some problems were encountered during the process:
Issue 1: Prompt for missing header file
HELLOWORLD.CPP:1:23: Error: qapplication: no file or directory
Helloworld.cpp:2:17: Error: Qlabel: no file or directory
Edit the first step Qmake-project generated Helloworld.pro
#vim Helloworld.pro
Join Qt+=widgets
Problem 2:error:cannot FIND-LGL
The reason is that the system lacks the corresponding OpenGL library files caused by the solution as follows:
Enter the terminal of the CentOS system, and then execute the following command, which can be solved. (still need root permission)
#yum Install Mesa-libgl-devel Mesa-libglu-devel
#yum Install Freeglut-devel