Hướng dẫn cài QT-Creator trên Ubuntu

Installation Guide (Hướng dẫn cài đặt)

  • Download

Visit Qt downloads page an download a 32-bit or 64-bit Linux installation depending your version of Ubuntu. The installation file can be also downloaded through the command line using wget. (thông qua link trên hoặc lệnh wqet ở dưới)

Example:

wget http://download.qt.io/official_releases/qt/5.7/5.7.0/qt-opensource-linux-x64-5.7.0.run
  • Install (cài QT creator)

Adjust permission, run the installer and follow the instruction to complete the installation. (cấp quyền để cài đặt)

chmod +x qt-opensource-linux-x64-5.7.0.run
./qt-opensource-linux-x64-5.7.0.run
  • Install g++ (cài bộ biên dịch g++ -> rất quan trọng)

Open a terminal and execute the following command to install g++: (mở terminal và gõ lệnh sau)

sudo apt-get install build-essential
  • Install generic font configuration library – runtime (cài các gói thư viện)

Open a terminal and execute the following command to install the full runtime files for the generic font configuration library: (mở terminal và gõ lệnh sau)

sudo apt-get install libfontconfig1
  • Configure a compiler

Launch Qt Creator. Go to Tools > Options. Click Build & Run and select tab Kit. Configure a compiler if it is not automatically detected. (cấu hình bộ biên dịch -> rất quan trọng)

  • Install OpenGL libraries

Execute the following command to install OpenGL libraries: (cài thư viện OpenGL)

sudo apt-get install mesa-common-dev

Note: Just installing the above-mentioned mesa-common-dev kit is not sufficient for more recent Ubuntu versions. Based on a comment in the Qt forum[1] an additional package needs installation. Execute following command:

sudo apt-get install libglu1-mesa-dev -y

Tested with Qt5.3.1 and it solved the problem with missing -lGL.

  • Set file association with pro files

When installing from the on-line source the file association is not done automatically. It also not show up when you try to associate it with file explorer. Create a file named “Qt-Creator.desktop” and fill the file with the following.

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Application
Name=QtCreator
Comment=QtCreator
NoDsiplay=true
Exec=(Install folder of QT)/Tools/QtCreator/bin/qtcreator %f
Icon=(Install folder of QT)/5.4/Src/qtdoc/doc/images/landing/icon_QtCreator_78x78px.png
Name[en_US]=Qt-Creator

Place this file in home .local/share/applications .

Edit a file named “defaults.list” in the same directory . Add the following line.

text/qtcreator=Qt-Creator.desktop;

open file mimeapps.list and check if the following line is present.

application/vnd.nokia.qt.qmakeprofile=qtcreator.desktop

if not add it under [added Associations].

Run the following command.

sudo update-mime-database /usr/share/mime

now Qt has been added to the list of file associations.

Troubleshooting (giải quyết 1 số sự cố, lỗi khi cài, chạy)

  • Qt Creator needs a compiler set up to build

Follow the instruction from the previous section to configure compiler for Qt Creator.

  • error: g++: Command not found

Solution:

sudo apt-get install build-essential
  • error: GL/gl.h: No such file or directory

Solution:

sudo apt-get install mesa-common-dev

Bình luận