At one point, the instruction advises you to install some libraries that are used throughout the book, by issuing the following command:
opam install \ async yojson core_extended core_bench \ cohttp async_graphics cryptokit menhir
At first I’ve failed to install the cohttp and async_graphics packages. Possibly that was because I already had objective-caml installed, and my process of installation deviated a bit from the one prescribed by the instruction.
The cohttp package depends on ctypes package, which was failing with the following error:
# fatal error: 'ffi.h' file not found # #include <ffi.h>
To solve it, just install libffi and add it to LDFLAGS environment variable for the time of build:
brew install libffi export LDFLAGS=-L/usr/local/opt/libffi/lib opam install cohttp
If during the installation of async_graphics module you receive an error:
# Error: Unbound module Graphics
That probably means you’ve installed objective-caml without the Graphics module, which may be verified by the listing:
ls /usr/local/opt/objective-caml/lib/ocaml/graphics*
If the listing is empty, then you should reinstall objective-caml with graphics:
brew uninstall objective-caml brew install objective-caml --with-x11
Now the process of installing the async_graphics package should work just fine:
opam install async_graphics