LoginSignup
2
0

More than 3 years have passed since last update.

macOSでの camlimages 5.0.1 のビルドに失敗し、それを解決するまで

Posted at

経緯

SATySFiを入れ直したら

$ opam install satysfi

<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><>
[satysfi.0.0.3] no changes from git+file:///Users/admin/SATySFi#master

The following actions will be performed:
  - install camlimages 5.0.1  [required by satysfi]
  - install satysfi    0.0.3*
===== 2 to install =====
Do you want to continue? [Y/n] y

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[camlimages.5.0.1] found in cache

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of camlimages failed at
        "/Users/admin/.opam/opam-init/hooks/sandbox.sh build jbuilder build -p
        camlimages -j 4".

#=== ERROR while compiling camlimages.5.0.1 ===================================#
# context     2.0.0 | macos/x86_64 |  | https://opam.ocaml.org#69f81992
# path        ~/.opam/4.05.0/.opam-switch/build/camlimages.5.0.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build jbuilder build -p camlimages -j 4
# exit-code   1
# env-file    ~/.opam/log/camlimages-84418-a00279.env
# output-file ~/.opam/log/camlimages-84418-a00279.out
### output ###
# [...]
# Use Stdlib instead.
# 
# If you need to stay compatible with OCaml < 4.07, you can use the 
# stdlib-shims library: https://github.com/ocaml/stdlib-shims
# File "tiff/tiff.ml", line 127, characters 6-25:
# 127 |       Pervasives.close_in ic;
#             ^^^^^^^^^^^^^^^^^^^
# Alert deprecated: module Stdlib.Pervasives
# Use Stdlib instead.
# 
# If you need to stay compatible with OCaml < 4.07, you can use the 
# stdlib-shims library: https://github.com/ocaml/stdlib-shims



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build camlimages 5.0.1
+- 
- No changes have been performed

と言われて上手く行かなかった。エラーメッセージでググってもほとんどなにもヒットしなかった。かなしい。

原因その1

SATySFiが要求するOCamlのバージョンがいつの間にか4.05.0ではなく4.06.0になっていた。 opam switch create 4.06.0 をする。

まだ直らん

$ opam install satysfi
The following actions will be performed:
  - install camlimages 5.0.1               [required by satysfi]
  - install satysfi    0.0.3+dev2019.07.14
===== 2 to install =====
Do you want to continue? [Y/n] y

<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[camlimages.5.0.1] found in cache
[satysfi.0.0.3+dev2019.07.14] synchronised from git+https://github.com/gfngfn/SATySFi.git#b1349fae80e43ac454bbcd9a7101c9988fe6aaa2

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of camlimages failed at
        "/Users/admin/.opam/opam-init/hooks/sandbox.sh build jbuilder build -p
        camlimages -j 4".

#=== ERROR while compiling camlimages.5.0.1 ===================================#
# context     2.0.0 | macos/x86_64 | ocaml-base-compiler.4.06.0 | https://opam.ocaml.org#69f81992
# path        ~/.opam/4.06.0/.opam-switch/build/camlimages.5.0.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build jbuilder build -p camlimages -j 4
# exit-code   1
# env-file    ~/.opam/log/camlimages-52267-2dea01.env
# output-file ~/.opam/log/camlimages-52267-2dea01.out
### output ###
# jpegread.c:282:10: warning: assigning to 'JSAMPROW' (aka 'unsigned char *') from 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
# [...]
# jpegread.c:296:10: warning: assigning to 'JSAMPROW' (aka 'unsigned char *') from 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
#   row[0] = String_val(buf) + Int_val(offset);
#          ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 2 warnings generated.
#   ocamlmklib tiff/dllcamlimages_tiff_stubs.so,tiff/libcamlimages_tiff_stubs.a (exit 2)
# (cd _build/default && /Users/admin/.opam/4.06.0/bin/ocamlmklib.opt -g -o tiff/camlimages_tiff_stubs tiff/tiffread.o tiff/tiffwrite.o -L/usr/local/Cellar/libtiff/4.0.9_4/lib -ltiff)
# ld: file not found: /usr/local/opt/jpeg/lib/libjpeg.9.dylib for architecture x86_64
# clang: error: linker command failed with exit code 1 (use -v to see invocation)
#   ocamlmklib xpm/dllcamlimages_xpm_stubs.so,xpm/libcamlimages_xpm_stubs.a
# /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: xpm/libcamlimages_xpm_stubs.a(xpmwrite.o) has no symbols
# /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: xpm/libcamlimages_xpm_stubs.a(xpmwrite.o) has no symbols



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build camlimages 5.0.1
+- 
- No changes have been performed

エラーメッセージは変化したが、ビルドはまだうまくいかない。

助け舟

SATySFi slack(ここのリンクから入れる)でsakas-- (Ken Sakayori)さんから以下のようなメッセージを頂いた。

Camlimagesのインストールで失敗しているのは共通していますが、2つのエラーの内容はだいぶ異なっていますね。
後者だとリンクで失敗しているみたいですが、libjpegはMacにインストールされていますか?

libjpeg、そんなものがあるのか。まあたしかにエラーメッセージをちゃんと読むと ld: file not found: /usr/local/opt/jpeg/lib/libjpeg.9.dylib for architecture x86_64 って書いてあるんだから、libjpegの不存在を直すのがよいのだなぁ。なるほど。ldがリンカであることを知っていながらなぜ思い当たらないのだ私は。

brew install libjpeg

brew install libjpeg をしたところ、「libjpegは入っているけど brew switch jpeg 9c するとよいかもね」と言われた。した。直った。

結論

エラーメッセージはよく読もう。

2
0
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
2
0