2017年3月12日日曜日

UbuntuでMissing (or bad) header file: zlib.hと言われた時の対処法

Linuxでcabalをインストールした時に次のエラーが出た。

 $ ./bootstrap.sh
...
Configuring zlib-0.5.4.1...
Setup: Missing dependency on a foreign library:
* Missing (or bad) header file: zlib.h
* Missing C library: z
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.

Error during cabal-install bootstrap:
Configuring the zlib package failed.

Missing (or bad) header file: zlib.h

zlibがないことによるものらしい。UbuntuやDebian系は zlib1g-dev という名前のパッケージをインストールすればよい。


 $ sudo apt-get install zlib1g-dev

Ubuntuで/usr/bin/ld: cannot find -lgmpと言われた時の対処法

cabalをソースからinstallした場合に次のようなエラーが出た。


$ ./bootstrap.sh
...
Linking Setup ...
/usr/bin/ld: cannot find -lgmp
collect2: error: ld returned 1 exit status

Error during cabal-install bootstrap:
Compiling the Setup script failed.

Ubuntuの場合、libgmp3-dev というパッケージを入れることで解決した。



$ sudo apt-get install libgmp3-dev