LoginSignup
3
2

More than 5 years have passed since last update.

Qt5 を Debian 9 にインストールする

Last updated at Posted at 2018-11-18

なぜ Qt5 を Debian 9 にインストールするのか?

こんにちは、chlochanです。今日は Qt5 を Debian 9 にインストールしてみます。なぜ、Debian 9 かというと、いま Deep Learningの勉強に使っている Google Cloud Platform の Deep Learning VM Image が Debian 9 なためです。そしてなんで Qt をインストールするかというと、Qt が好きだからです。

Install Qt 5 on Debian

wiki.qt.ioで探して見ましたが、Debian向けののインストール方法はなかったので、Ubuntu向けの以下のインストール方法を参考にインストールします。
https://wiki.qt.io/Install_Qt_5_on_Ubuntu

まず、インストーラーをダウンロードします。2018/11/18時点での最新版は 5.11.2 です。

$ wget http://download.qt.io/official_releases/qt/5.11/5.11.2/qt-opensource-linux-x64-5.11.2.run

run ファイルに実行属性をつけて実行し、Qt5 をインストールします。

$ chmod +x qt-opensource-linux-x64-5.11.2.run
$ ./qt-opensource-linux-x64-5.11.2.run

g++ をインストールします。

$ sudo apt-get install build-essential

フォントライブラリをインストールします。

$ sudo apt-get install libfontconfig1

Qt Creatorを起動します。 Tools > Options を選択します。 Kits をクリックし、 Compilers タブ を選択します。 コンパイラが、自動的に検出(Auto-detected)、されていない場合は、手動でコンパイラを設定します。

OpenGL のライブラリをインストールします。

$ sudo apt-get install mesa-common-dev

以下の追加パッケージのインストールも必要です。次のコマンドを実行します。この追加パッケージのインストールで、-lGL が見つからない、という問題が起こる事を防げます。

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

上記の方法でダウンロードしてインストールする場合、ファイルの関連付けは自動的には行われません。よって関連づけるため、"Qt-Creator.desktop" という名前のファイルを作成し、ファイルに次のように入力します。なお、<ユーザー名> のところはインストールしたユーザー名にします。

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Application
Name=QtCreator
Comment=QtCreator
NoDsiplay=true
Exec=/home/<ユーザー名>/Qt5.11.2/Tools/QtCreator/bin/qtcreator %f
Icon=/home/<ユーザー名>/Qt5.11.2/5.11.2/Src/qtdoc/doc/images/landing/icon_QtCreator_78x78px.png
Name[en_US]=Qt-Creator

このファイルを自分のホームディレクトリの .local/share/applications に置きます。
また、同じディレクトリ内の "defaults.list" という名前のファイルに次の行を追加します。ファイルがなければ作成します。

text/qtcreator=Qt-Creator.desktop; 

ファイル /usr/share/applications/mimeapps.list を開き、次の行が存在しているか確認します。もし無い場合は、[added Associations] の下に追加します。

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

もし、ファイル /usr/share/applications/mimeapps.list そのものが無い場合は作成し、ファイルに次のように入力します。

[added Associations]
application/vnd.nokia.qt.qmakeprofile=qtcreator.desktop

次のコマンドを実行します。

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

これで Qt がファイルの関連付けリストに追加されました。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2