b a d p o p c o r n

MacPorts and Gambit-C

Written by Ben on May 22, 2007 |

The Gambit-C MacPorts Portfile was finally committed a couple days ago, and I just got around to trying it out. Just do a `sudo port -d selfupdate`, and `port install gambit-c`. Worked like a charm! Great Job Arto! :)

Just a few notes about the installation for those that are trying out the examples from the Gambit-C user manual:

  • gsc needs “-l /opt/local/lib/gambit-c/_gambc” when generating link files.
  • Pass the following to gcc for gambit.h: -I/opt/local/include

Using an example taken from the users manual:

Here is for example how a program with three modules (one in C and
two in Scheme) can be built. The content of the three source files
(`m1.c’, `m2.scm’ and `m3.scm’) is:

/* File: “m1.c” */
int power_of_2 (int x) { return 1<<x; }

; File: “m2.scm”
(c-declare “extern int power_of_2 ();”)
(define pow2 (c-lambda (int) int “power_of_2″))
(define (twice x) (cons x x))

; File: “m3.scm”
(write (map twice (map pow2 ‘(1 2 3 4)))) (newline)

The compilation of the two Scheme source files can be done with
three invocations of `gsc’:

$ gsc -c m2.scm # create m2.c (note: .scm is optional)
$ gsc -c m3.scm # create m3.c (note: .scm is optional)
$ gsc -link m2.c m3.c # create the incremental link file m3_.c

We, instead, use the following command lines:

# optional compile into C files.
$ gsc -c m2.scm # create m2.c (note: .scm is optional)
$ gsc -c m3.scm # create m3.c (note: .scm is optional)
# creates the link file (m3_.c) and creates m1.c m2.c if they don’t exist.
$ gsc -link -l /opt/local/lib/gambit-c/_gambc m2 m3
# Compiles the code into a.out
gcc -I/opt/local/include m1.c m2.c m3.c m3_.c -L/opt/local/lib/gambit-c -lgambc

Posted in OpenSource, Technology


1 Comment »

  1. [...] I wish to find a better way for Termite to be installed without recompiling Gambit-C; all because– you know– I use the Gambit-C MacPort. [...]

    Pingback by BadPopcorn » Termite, Gambit-C Wish — June 12, 2007 @ 9:51 am

RSS feed for comments on this post. | TrackBack URI

Leave a comment

XHTML ( You can use these tags): <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .