Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac OS X installation: [ERROR] The compilation of ctypes failed at "make". #57

Open
laowantong opened this issue Jan 25, 2017 · 15 comments

Comments

@laowantong
Copy link

I have just installed a binary of OPAM with the official script on Mac OS X Yosemite 10.10.5, XCode 7.2.1. Now, trying to install iocaml works fine until make fails on ctypes. Various errors follow. Relaunching the installation produces the following:

MacBook-Air:~ username$ opam install iocaml
The following actions will be performed:
  ∗  install iocamljs-kernel 0.4.8            [required by iocaml]
  ∗  install ctypes          0.3.4            [required by iocaml]
  ∗  install iocaml-kernel   0.4.8            [required by iocaml]
  ∗  install iocaml          0.4.8
===== ∗  4 =====
Do you want to continue ? [Y/n] Y

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
[ctypes] Archive in cache
[iocaml] Archive in cache
[iocaml-kernel] Archive in cache
[iocamljs-kernel] Archive in cache

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
[ERROR] The compilation of iocamljs-kernel failed at "make clean min".
[ERROR] The compilation of ctypes failed at "make".
Processing  2/4: [ctypes: ocamlfind remove]
#=== ERROR while installing ctypes.0.3.4 ======================================#
# opam-version 1.2.2
# os           darwin
# command      make
# path         /Users/username/.opam/4.02.1/build/ctypes.0.3.4
# compiler     4.02.1
# exit-code    2
# env-file     /Users/username/.opam/4.02.1/build/ctypes.0.3.4/ctypes-92056-e7966f.env
# stdout-file  /Users/username/.opam/4.02.1/build/ctypes.0.3.4/ctypes-92056-e7966f.out
# stderr-file  /Users/username/.opam/4.02.1/build/ctypes.0.3.4/ctypes-92056-e7966f.err
### stdout ###
# [...]
# ocamlfind ocamlc -c -o _build/src/ctypes-foreign-base/libffi_abi.cmi    -I _build/src/ctypes-foreign-base  -I _build/src/ctypes src/ctypes-foreign-base/libffi_abi.mli
# ocamlfind ocamlc      -c -o _build/src/ctypes-foreign-base/libffi_abi.cmo -I _build/src/ctypes-foreign-base  -I _build/src/ctypes src/ctypes-foreign-base/libffi_abi.ml
# ocamlfind ocamlc -c -o _build/src/ctypes-foreign-base/weakRef.cmi    -I _build/src/ctypes-foreign-base  -I _build/src/ctypes src/ctypes-foreign-base/weakRef.mli
# ocamlfind ocamlc      -c -o _build/src/ctypes-foreign-base/weakRef.cmo -I _build/src/ctypes-foreign-base  -I _build/src/ctypes src/ctypes-foreign-base/weakRef.ml
# ocamlfind ocamlc -c -o _build/src/ctypes-foreign-base/ffi.cmi    -I _build/src/ctypes-foreign-base  -I _build/src/ctypes src/ctypes-foreign-base/ffi.mli
# ocamlfind ocamlc      -c -o _build/src/ctypes-foreign-base/ffi.cmo -I _build/src/ctypes-foreign-base  -I _build/src/ctypes src/ctypes-foreign-base/ffi.ml
# ocamlfind ocamlc      -c -o _build/src/ctypes-foreign-base/foreign_basis.cmo -I _build/src/ctypes-foreign-base  -I _build/src/ctypes src/ctypes-foreign-base/foreign_basis.ml
# ocamlfind ocamlc -a   -cclib -lctypes-foreign-base_stubs -dllib -lctypes-foreign-base_stubs   -o _build/ctypes-foreign-base.cma _build/src/ctypes-foreign-base/closure_properties.cmo _build/src/ctypes-foreign-base/dl.cmo _build/src/ctypes-foreign-base/ffi_stubs.cmo _build/src/ctypes-foreign-base/libffi_abi.cmo _build/src/ctypes-foreign-base/weakRef.cmo _build/src/ctypes-foreign-base/ffi.cmo _build/src/ctypes-foreign-base/foreign_basis.cmo 
# cd _build/src/ctypes-foreign-base && ocamlfind ocamlc -c -ccopt -fPIC -ccopt -Wall -ccopt -O3 -ccopt -I -ccopt /Users/username/src -ccopt -I -ccopt /Users/username/tests -o dl_stubs.o  /Users/username/.opam/4.02.1/build/ctypes.0.3.4/src/ctypes-foreign-base/dl_stubs.c
# cd _build/src/ctypes-foreign-base && ocamlfind ocamlc -c -ccopt -fPIC -ccopt -Wall -ccopt -O3 -ccopt -I -ccopt /Users/username/src -ccopt -I -ccopt /Users/username/tests -o ffi_call_stubs.o  /Users/username/.opam/4.02.1/build/ctypes.0.3.4/src/ctypes-foreign-base/ffi_call_stubs.c
### stderr ###
# /Users/username/.opam/4.02.1/build/ctypes.0.3.4/src/ctypes-foreign-base/ffi_call_stubs.c:21:10: fatal error: 'ffi.h' file not found
# #include <ffi.h>
#          ^
# 1 error generated.
# make: *** [_build/src/ctypes-foreign-base/ffi_call_stubs.o] Error 2


#=== ERROR while installing iocamljs-kernel.0.4.8 =============================#
# opam-version 1.2.2
# os           darwin
# command      make clean min
# path         /Users/username/.opam/4.02.1/build/iocamljs-kernel.0.4.8
# compiler     4.02.1
# exit-code    2
# env-file     /Users/username/.opam/4.02.1/build/iocamljs-kernel.0.4.8/iocamljs-kernel-92056-d8a4ae.env
# stdout-file  /Users/username/.opam/4.02.1/build/iocamljs-kernel.0.4.8/iocamljs-kernel-92056-d8a4ae.out
# stderr-file  /Users/username/.opam/4.02.1/build/iocamljs-kernel.0.4.8/iocamljs-kernel-92056-d8a4ae.err
### stdout ###
# rm -f *.cmis.js
# rm -f *.cm[ioa] iocaml_full.byte iocaml.byte iocaml.js 
# rm -fr *~
# ocamlfind ocamlc -c exec.mli
# ocamlfind ocamlc -c \
# 		-syntax camlp4o -package js_of_ocaml.syntax,optcomp \
# 		-package str,dynlink,js_of_ocaml,js_of_ocaml.compiler,js_of_ocaml.toplevel \
# 		-I /Users/username/.opam/4.02.1/lib/ocaml/compiler-libs \
# 		exec.ml
### stderr ###
# ocamlfind: Package `js_of_ocaml.toplevel' not found
# make: *** [exec.cmo] Error 2



=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
The following actions were aborted
  ∗  install iocaml        0.4.8
  ∗  install iocaml-kernel 0.4.8
The following actions failed
  ∗  install ctypes          0.3.4
  ∗  install iocamljs-kernel 0.4.8
No changes have been performed

=-=- ctypes.0.3.4 troobleshooting -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
=> This package relies on external (system) dependencies that may be missing. `opam depext ctypes.0.3.4' may help you find the correct
   installation for your system.
MacBook-Air:~ username$ opam depext ctypes.0.3.4
# Detecting depexts using flags: x86_64 osx
# No extra OS packages requirements found.

Any help in solving this would be appreciate!

@andrewray
Copy link
Owner

andrewray commented Jan 25, 2017 via email

@yallop
Copy link
Contributor

yallop commented Jan 25, 2017

It's a little surprising that the depext command isn't finding anything. Do you have Homebrew or MacPorts installed?

@laowantong
Copy link
Author

@yallop Not at all.

@andrewray Thanks, unfortunately that still fails:

MacBook-Air:~ username$ opam install ctypes.0.11.2 iocaml
The following actions will be performed:
  ∗  install conf-pkg-config 1.0              [required by ctypes]
  ∗  install iocamljs-kernel 0.4.8            [required by iocaml]
  ∗  install ctypes          0.11.2
  ∗  install iocaml-kernel   0.4.8            [required by iocaml]
  ∗  install iocaml          0.4.8 
===== ∗  5 =====
Do you want to continue ? [Y/n] Y

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
[iocaml] Archive in cache
[iocaml-kernel] Archive in cache
[iocamljs-kernel] Archive in cache
[default] https://opam.ocaml.org/archives/ctypes.0.11.2+opam.tar.gz downloaded

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
∗  installed conf-pkg-config.1.0
[ERROR] The compilation of iocamljs-kernel failed at "make clean min".
[ERROR] The compilation of ctypes failed at "make XEN=disable ctypes-foreign".
Processing  3/5: [ctypes: ocamlfind remove]
#=== ERROR while installing ctypes.0.11.2 =====================================#
# opam-version 1.2.2
# os           darwin
# command      make XEN=disable ctypes-foreign
# path         /Users/username/.opam/4.02.1/build/ctypes.0.11.2
# compiler     4.02.1
# exit-code    2
# env-file     /Users/username/.opam/4.02.1/build/ctypes.0.11.2/ctypes-96572-d0f245.env
# stdout-file  /Users/username/.opam/4.02.1/build/ctypes.0.11.2/ctypes-96572-d0f245.out
# stderr-file  /Users/username/.opam/4.02.1/build/ctypes.0.11.2/ctypes-96572-d0f245.err
### stdout ###
# [...]
# ocamlfind  ocamlopt -bin-annot -c -o _build/src/ctypes-foreign-base/dl.cmi -package bytes    -principal -short-paths -g -I _build/src/ctypes-foreign-base  -I _build/src/ctypes src/ctypes-foreign-base/dl.mli
# ocamlfind  ocamlc -package bytes   -principal -short-paths -g   -c -o _build/src/ctypes-foreign-base/dl.cmo -I _build/src/ctypes-foreign-base  -I _build/src/ctypes src/ctypes-foreign-base/dl.ml
# ocamlfind  ocamlopt -bin-annot -c -o _build/src/ctypes-foreign-base/libffi_abi.cmi -package bytes    -principal -short-paths -g -I _build/src/ctypes-foreign-base  -I _build/src/ctypes src/ctypes-foreign-base/libffi_abi.mli
# ocamlfind  ocamlc -package bytes   -principal -short-paths -g   -c -o _build/src/ctypes-foreign-base/libffi_abi.cmo -I _build/src/ctypes-foreign-base  -I _build/src/ctypes src/ctypes-foreign-base/libffi_abi.ml
# ocamlfind  ocamlopt -bin-annot -c -o _build/src/ctypes-foreign-base/ctypes_ffi.cmi -package bytes    -principal -short-paths -g -I _build/src/ctypes-foreign-base  -I _build/src/ctypes src/ctypes-foreign-base/ctypes_ffi.mli
# ocamlfind  ocamlc -package bytes   -principal -short-paths -g   -c -o _build/src/ctypes-foreign-base/ctypes_ffi.cmo -I _build/src/ctypes-foreign-base  -I _build/src/ctypes src/ctypes-foreign-base/ctypes_ffi.ml
# ocamlfind  ocamlc -package bytes   -principal -short-paths -g   -c -o _build/src/ctypes-foreign-base/ctypes_foreign_basis.cmo -I _build/src/ctypes-foreign-base  -I _build/src/ctypes src/ctypes-foreign-base/ctypes_foreign_basis.ml
# ocamlfind  ocamlc -a -principal -short-paths -g  -cclib -lctypes-foreign-base_stubs -dllib -lctypes-foreign-base_stubs -package bytes   -o _build/ctypes-foreign-base.cma _build/src/ctypes-foreign-base/ctypes_closure_properties.cmo _build/src/ctypes-foreign-base/ctypes_ffi_stubs.cmo _build/src/ctypes-foreign-base/ctypes_weak_ref.cmo _build/src/ctypes-foreign-base/dl.cmo _build/src/ctypes-foreign-base/libffi_abi.cmo _build/src/ctypes-foreign-base/ctypes_ffi.cmo _build/src/ctypes-foreign-base/ctypes_foreign_basis.cmo -cclib -lffi
# cd _build/src/ctypes-foreign-base && ocamlfind  ocamlc -c -package bytes   -ccopt -fPIC -ccopt -Wall -ccopt -g -ccopt -I -ccopt /Users/username/.opam/4.02.1/build/ctypes.0.11.2/src/ctypes -ccopt -I -ccopt /Users/username/.opam/4.02.1/build/ctypes.0.11.2/tests -o dl_stubs.o -principal -short-paths -g /Users/username/.opam/4.02.1/build/ctypes.0.11.2/src/ctypes-foreign-base/dl_stubs.c
# cd _build/src/ctypes-foreign-base && ocamlfind  ocamlc -c -package bytes   -ccopt -fPIC -ccopt -Wall -ccopt -g -ccopt -I -ccopt /Users/username/.opam/4.02.1/build/ctypes.0.11.2/src/ctypes -ccopt -I -ccopt /Users/username/.opam/4.02.1/build/ctypes.0.11.2/tests -o ffi_call_stubs.o -principal -short-paths -g /Users/username/.opam/4.02.1/build/ctypes.0.11.2/src/ctypes-foreign-base/ffi_call_stubs.c
### stderr ###
# /Users/username/.opam/4.02.1/build/ctypes.0.11.2/src/ctypes-foreign-base/ffi_call_stubs.c:22:10: fatal error: 'ffi.h' file not found
# #include <ffi.h>
#          ^
# 1 error generated.
# make: *** [_build/src/ctypes-foreign-base/ffi_call_stubs.o] Error 2


#=== ERROR while installing iocamljs-kernel.0.4.8 =============================#
# opam-version 1.2.2
# os           darwin
# command      make clean min
# path         /Users/username/.opam/4.02.1/build/iocamljs-kernel.0.4.8
# compiler     4.02.1
# exit-code    2
# env-file     /Users/username/.opam/4.02.1/build/iocamljs-kernel.0.4.8/iocamljs-kernel-96572-c61e7b.env
# stdout-file  /Users/username/.opam/4.02.1/build/iocamljs-kernel.0.4.8/iocamljs-kernel-96572-c61e7b.out
# stderr-file  /Users/username/.opam/4.02.1/build/iocamljs-kernel.0.4.8/iocamljs-kernel-96572-c61e7b.err
### stdout ###
# rm -f *.cmis.js
# rm -f *.cm[ioa] iocaml_full.byte iocaml.byte iocaml.js 
# rm -fr *~
# ocamlfind ocamlc -c exec.mli
# ocamlfind ocamlc -c \
# 		-syntax camlp4o -package js_of_ocaml.syntax,optcomp \
# 		-package str,dynlink,js_of_ocaml,js_of_ocaml.compiler,js_of_ocaml.toplevel \
# 		-I /Users/username/.opam/4.02.1/lib/ocaml/compiler-libs \
# 		exec.ml
### stderr ###
# ocamlfind: Package `js_of_ocaml.toplevel' not found
# make: *** [exec.cmo] Error 2



=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=  🐫 
The following actions were aborted
  ∗  install iocaml        0.4.8
  ∗  install iocaml-kernel 0.4.8
The following actions failed
  ∗  install ctypes          0.11.2
  ∗  install iocamljs-kernel 0.4.8 
The following changes have been performed
  ∗  install conf-pkg-config 1.0

@andrewray
Copy link
Owner

andrewray commented Jan 25, 2017 via email

@laowantong
Copy link
Author

Installing homebrew fails too 😞

MacBook-Air:~ username$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following new directories will be created:
/usr/local/Cellar
/usr/local/Homebrew
/usr/local/Frameworks
/usr/local/opt
/usr/local/sbin
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir -p /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
Password:
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
==> /usr/bin/sudo /usr/sbin/chown username /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/opt /usr/local/sbin /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /bin/mkdir -p /Users/username/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/username/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown username /Users/username/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown username /Library/Caches/Homebrew
==> Downloading and installing Homebrew...
warning: templates not found /Users/sabae/tmp/julia-packaging/osx/julia-master/usr/share/git-core/templates
fatal: Unable to find remote helper for 'https'
Failed during: git fetch origin master:refs/remotes/origin/master --tags --force --depth=1

Don't know why it is looking for a user named sabae. For Julia, I remember having installed it a long time ago. Anyway, this is just a warning, may be unrelated to the fatal error.

Concerning:

opam install js_of_ocaml.2.8.3 iocaml

it fails too, but I guess it's normal since libffi is still missing.

@laowantong
Copy link
Author

Actually it seems that I already have libffi in several places (I just kept 3 in the following):

$ locate libffi
/Applications/Dropbox.app/Contents/Frameworks/libffi.6.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib/libffi.tbd
/usr/lib/libffi.dylib

@andrewray
Copy link
Owner

Can you see ffi.h? On my (linux) system I need a package called libffi-dev to get the header files.

@laowantong
Copy link
Author

Yes, in two places:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/ffi/ffi.h
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/MacOSX.sdk/usr/include/ffi/ffi.h

@yallop
Copy link
Contributor

yallop commented Jan 25, 2017

@laowantong, you may be able to fix this by setting the LIBFFI_CFLAGS and LIBFFI_LIBS environment variables when installing ctypes. More details here: https://github.com/ocamllabs/ocaml-ctypes/blob/e66d23ea56fad3ef7c6b2c6955bebb06b01cb2d2/Makefile#L200-L209

That said, the recommended approach is to install libffi via MacPorts or Homebrew, if possible. The system-installed libffi is often so old that it lacks features required by ctypes.

@laowantong
Copy link
Author

laowantong commented Jan 25, 2017

@yallop Thanks. Since all of this is far above my head, I am not quite sure which replacement is required, tentatively:

export LIBFFI_CFLAGS=-I//Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/ffi/include
export LIBFFI_LIBS=\"-L//Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/ffi/lib -lffi\"

But the latter is rejected with the following message:

-bash: export: `-lffi': not a valid identifier

Sorry for having taken too much of your time, but I think I am going to give up here. I have tried the recommended approach (with homebrew) last year, with no more success, going deeper and deeper into the rabbit hole with no result at the end of the day.

@yallop
Copy link
Contributor

yallop commented Jan 25, 2017

The double quotes (in the LIBFFI_LIBS) shouldn't be preceded by \:

export LIBFFI_CFLAGS=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/ffi/include
export LIBFFI_LIBS="-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/ffi/lib -lffi"

@laowantong
Copy link
Author

OK, this one was really stupid, sorry. After the correction, installing ctypes fails later:

### stderr ###
# /Users/username/.opam/4.02.1/build/ctypes.0.11.2/src/ctypes-foreign-base/ffi_call_stubs.c:22:10: fatal error: 'ffi.h' file not found
# #include <ffi.h>
#          ^
# 1 error generated.
# make: *** [_build/src/ctypes-foreign-base/ffi_call_stubs.o] Error 2

@yallop
Copy link
Contributor

yallop commented Jan 25, 2017

That looks like progress. Does the following help things along any further?

export LIBFFI_CFLAGS=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/ffi/
export LIBFFI_LIBS="-L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib -lffi"

(The directories in the above should be the respective locations of the header file (ffi.h) and the shared library.)

@laowantong
Copy link
Author

Yes, this goes further.

Not sure what to do next:

opam install js_of_ocaml.2.8.3 iocaml

... gives some new errors I think:

[ERROR] The compilation of iocamljs-kernel failed at "make clean min".
[ERROR] The compilation of iocaml-kernel failed at "make all".
...
### stderr ###
# iocaml_zmq_stubs.c:1:10: fatal error: 'zmq.h' file not found
# #include <zmq.h>
#          ^
# 1 error generated.
# make: *** [stub] Error 2

Same thing with the original command:

opam install iocaml

And this time, zmq.h is nowhere to be found.

@andrewray
Copy link
Owner

The iocamljs-kernel failure I will have a look into and try to find some set of working package versions.

For iocaml, just like libffi, you will need a development version of zmq3 or 4 installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants