Building Guile 2.0 on the Mac
Introduction
Guile 2.0 was just released in February so neither Fink nor MacPorts have support for it yet. There's no reason to wait, though. It's easy to build Guile from the source distribution. The only problem is that Mac OS X is missing several of the libraries that Guile needs, so they must be compiled and installed first.
In the step-by-step directions below, I have you rerun configure
after each step rather than trying to compile and install all the
libraries first. That's because your system may have fewer or more
missing libraries than mine and rerunning configure
will tell you what
you need to do next.
Note that you'll need to be root or use sudo
when running make install
.
Step-by-step instructions
- Go to the Gnu Guile Web site and download the latest stable release (2.0.0 as of this writing).
-
Untar the source into the directory where Guile will live, change
into that directory and run
configure
. Unless you have a current Gnu multiple precision library installed,configure
will return an error saying:Gnu MP 4.1 or greater not found, see README
-
If you don't get this error, you already have Gnu MP installed; go on
to step 4.
a. Otherwise, retrieve Gnu MP from the GMP Web site. I used the latest stable release, GMP 4.3.2 but there is also a “performance release,” GMP 5.0.1.
b. Run
configure
with the build option:./configure --build=x86_64-apple-darwin10
If you don't specify the
build
option, the MP library will be built for a generic x86 system and the Guileconfigure
script will fail again with the same error. Ifx86_64-apple-darwin10
does not describe your system, check the Guileconfig.log
file to see what it's expecting.c. Run
make check
. This will exercise the library and make sure everything was built correctly.d. Run
make install
-
Change back to the Guile directory and rerun
configure
. The next error will tell you the next missing library. I gotconfigure: error: GNU libunistring is required, please install it.
a. Retrieve
libunistring
from the libunistring Web site and untar it into a working directory.b. Do the usual
configure
/make
/make install
dance to make and install the library. -
Return to the Guile directory and rerun
configure
. This timeconfigure
will complain about a missingpkg-config
script. If you don't get this error go on to step 6.a. Retrieve
pkg-script
from the pkg-config Wiki.b. Untar it into a working directory and run
configure
/make
/make install
. -
Return to the Guile directory and rerun configure. This time
configure
will complain about a missinglibffi
. If you did not get this error, go on to step 7.a. Retrieve the library from the libffi Web site.
b. Untar the library into a working directory and run
configure
/make
/make install
. -
Return to the Guile directory and rerun configure. The
configure
script will complain about a missing BDW-gc library.a. Go to http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/ and down load the source for Version 7.1. Note that the stable version does not compile on the Mac.
b. Untar the source into a working directory and do the usual
configure
/make
/make check
/make install
. At some point (either during themake
or themake check
you might get an error complaining that theucontext
routines are deprecated and that you need to specify _XOPEN_SOURCE. I did this by editing the source formach_dep.c
and including the statement#define _XOPEN_SOURCE
right before the
#include <ucontext.h>
-
Return to the Guile directory and rerun
configure
. This timeconfigure
should finish normally and you can try compiling Guile. If you get an error about the missing symbol_rl_get_keymap_name
, you will need to go to the readline library Web page and get the latest version of the library. Before you build the library, delete or rename thelibreadline
that is in/usr/lib
. That version of the library is the BSD version supplied by Apple and is no longer compatible. Then build and install the newlibreadline
with the usualconfigure
/make
/make install
. Return to the Guile directory and runmake clean
. Then rerun themake
. If you don't run themake clean
Guile may sigfault when you try to run it. Check out your build by runningmake check
and then do themake install
. At this point you should have a working version of Guile 2.0.
Very helpful and intuitively written article. I was installing MEEP (for simulation in physics) on my Mac.
ReplyDeleteAs a precursor to that I needed to install guile.I did got the error message as in step 2(Gnu MP 4.1 or greater not found, see README).
I installed gmp 5.0.2,with configure/make check/ install, I also specified the build, but instead of error of missing library I again got same error message" Gnu MP 4.1 or ..........README"
Whats wrong, any clues???
I used 4.3.2 and was able to get it to compile after messing with the build variable. Try 4.3.2 and see if that works. If not you will have to look at config.log to see what build string it is actually expecting. That may depend on how old your Mac is for example.
ReplyDeleteBy now, there may be Guile packages on Fink, Homebrew, or MacPorts if you can't get Gnu MP to install.
I installed guile and gmp from mac ports, pretty easy!!
ReplyDeletekiittos! thanks!
Thanks for the hint about the obsolete readline. I was just about to start banging my head on the keyboard... However I didn't remove the old library, just in case, but exported new LDFLAGS before configuring and making guile.
ReplyDeleteThe steps provided were very helpful, but I ran into three additional issues installing Guile v2.0.9 on my Mac OS X (uname ==> Darwin Kernel Version 12.4.0: Wed May 1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64)
ReplyDelete(1) I wound up needing to rebuild libiconv-1.14 (http://ftp.gnu.org/gnu/libiconv/)
(2) I used gc-7.3alpha2 (which asked for libatomic_ops-7.3alpha2) instead of version 7.1.
(3) A number of the scripts in guile-2.0.9/build-aux have a boogered-up she-bang line. Something akin to:
#!/nix/store/ryk1ywzz31kp4biclxq3yq6hpjycalyy-bash-4.2/bin/sh
instead of:
#!/bin/sh
This caused a failure to build that manifested with:
MacOShost:guile-2.0.9 user$ make
make all-recursive
Making all in lib
GEN alloca.h
GEN c++defs.h
GEN warn-on-use.h
GEN arg-nonnull.h
make[2]: ../build-aux/install-sh: Permission denied
make[2]: *** [arpa/inet.h] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
I fixed this by running this one-liner from within build-aux:
for fi in * ; do sed 's/^#!\/nix\/store\/.*\/bin\/sh$/#!\/bin\/sh/' "$fi" > zgtmp ; mv zgtmp "$fi"; chmod 744 "$fi" ; done
After that, guile compiled while I smiled.
Doh! Wrong set of errors. Should be:
Delete$ make
make all-recursive
Making all in lib
GEN alloca.h
GEN c++defs.h
GEN warn-on-use.h
GEN arg-nonnull.h
make[2]: ../build-aux/install-sh: No such file or directory
make[2]: *** [arpa/inet.h] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
The "Permission denied" was due to a mistake unique to my system.