Ubuntu 18.04 LTS Desktopにおいて、C関連のコンパイル環境を構築するため、build-essentialをインストールします。
記事の目次
使用した環境
- Ubuntu 18.04.03 LTS Desktop
aptコマンドでbuild-essiontialをインストール(エラー発生)
本来、以下のコマンドでインストールできるはずですが、エラーが発生してインストールできません。
$ sudo apt install build-essential Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: build-essential : Depends: dpkg-dev (>= 1.17.11) but it is not going to be installed E: Unable to correct problems, you have held broken packages.
依存関係を解決しながらインストール
そこで、依存関係を解決しながらインストールを試みます。dpkg-devのインストールを試みますが以下の状態で失敗します。
$ sudo apt install dpkg-dev Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: dpkg-dev : Depends: libdpkg-perl (= 1.19.0.5ubuntu2) but 1.19.0.5ubuntu2.1 is to be installed Recommends: build-essential but it is not going to be installed Recommends: fakeroot Recommends: libalgorithm-merge-perl but it is not going to be installed E: Unable to correct problems, you have held broken packages.
とりあえず、fakerootをインストールします。
$ sudo apt install fakeroot
次に、libalgorithm-merge-perlをインストールします。
$ sudo apt install libalgorithm-merge-perl
これらのパッケージはうまくインストールされます。ここで、libdpkg-perlをダウングレードします。
$ sudo apt install libdpkg-perl=1.19.0.5ubuntu2 Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: debian-keyring git bzr The following packages will be DOWNGRADED: libdpkg-perl 0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded. Need to get 211 kB of archives. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] Get:1 http://jp.archive.ubuntu.com/ubuntu bionic/main amd64 libdpkg-perl all 1.19.0.5ubuntu2 [211 kB] Fetched 211 kB in 0s (611 kB/s) dpkg: warning: downgrading libdpkg-perl from 1.19.0.5ubuntu2.1 to 1.19.0.5ubuntu2 (Reading database ... 170576 files and directories currently installed.) Preparing to unpack .../libdpkg-perl_1.19.0.5ubuntu2_all.deb ... Unpacking libdpkg-perl (1.19.0.5ubuntu2) over (1.19.0.5ubuntu2.1) ... Setting up libdpkg-perl (1.19.0.5ubuntu2) ... Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
すると、dpkg-devが以下のコマンドでインストール可能になります。
$ sudo apt install dpkg-dev
もう一度、build-essentialのインストールを試みますが、dpkg-devのインストール時にインストールされるため、追加インストールが不要であることがわかります。
$ sudo apt install build-essential Reading package lists... Done Building dependency tree Reading state information... Done build-essential is already the newest version (12.4ubuntu1). build-essential set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.