Install Qt5.6.1 under Linux

Source: Internet
Author: User

My environment: CentOS 6.7 64-bit.

1. Download qt:

QT version has a lot, their own comparison of dishes, I hope the installation process the simpler the better, feel more new version will be good to install some, 5.4 version also to update the/usr/lib64/libstdc++.so.6 file, 5.6 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 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 files in the directory, generally 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

You can then install the #./qt-opensource-linux-x64-5.6.1.run.

The installation process will be more smooth, all the way to a point point.

3. Configure Environment variables

You can run Qtcreator if you go to the directory where Qtcreator is located, but it can be cumbersome to add to the system environment variable each time.

#vim/etc/profile behind that file is to store environment variables, if not get root permissions This file is read-only, so want to modify it will first get permission (I compare vegetables also lazy directly first #su, back also do not have #sudo xxx).

In the file, add:

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.

After that, #qtcreator can start qtcreator.

If you want to develop with QT under the command line, you need to qmake the tool and add it to the environment variable in the same way as above.

The path in My computer is/opt/qt5.6.1/5.6/gcc_64.

Next try our first program HelloWorld.

Select a directory to create our project folder HelloWorld and enter.

#vim Helloworld.cpp

Edit the contents as follows:

#include <QApplication>  #include<QLabel>  int main (int argc,  Char *argv[])  {  qapplication app (ARGC,ARGV);   *label=New Qlabel ("helloworld! "  );  Label, Show ();     return app.exec ();  }  

Once saved, you can start compiling.

#qmake-project

This step will find 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 successfully.

Encountered some problems in the process:

Issue 1: Tip 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

Question 2:error:cannot FIND-LGL

The reason is that the system lacks the corresponding OpenGL library file resulting in the solution as follows:

Enter the terminal of the CentOS system and execute the following command in turn to resolve it. (Root permission is still required)

#yum Install Mesa-libgl-devel Mesa-libglu-devel

#yum Install Freeglut-devel

Install Qt5.6.1 under Linux

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.