I've made a simple project available for git cloning at:
https://bywicket.codebasehq.com/gnomeworks/libhellogambit/tree/master
libHelloGambit is a small collection of minimal projects that build static libraries from Scheme source code using Gambit Scheme, and that provide equally minimal example applications that link against those libraries.
Only two examples are provided in Release 1: one that builds and runs on Mac OS X, and one that builds and runs on the iOS simulator. I'll add more as work progresses on my actual project.
Below is the README, also available from the git repo.
If you have any trouble with the repo (sometimes I misremember how to properly make things public at codebasehq), drop me a line and I'll fix it.
--me
------ README ------
libHelloGambit Released into the Public Domain by mikel evins December 27th, 2010 Release 1
ABOUT
libHelloGambit is a minimal project that demonstrates simply how to build a static library from Scheme sources, using the Gambit Scheme compiler, so that the library can be linked against ordinary applications on several target platforms. The working platforms in Release 1 are Mac OS X 10.6, using Apple's XCode 3.2.5, and the Apple iOS Simulator using the same development tools.
I hope that it's clear from examining the included files how to adapt them for use with additional platforms that Gambit supports; in case it isn't, I plan to make additional releases of the project adding working examples for the iOS device SDK, Windows, and Linux.
PREPARATIONS
For Mac OS X and iOS builds, you'll need Apple's Mac OS X and iOS SDKs, available from http://developer.apple.com.
In order to build the examples provided with libHelloGambit, you must first obtain the source distribution of Gambit Scheme from:
http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php/Main_Page
You will need to build these sources using a script ("build-gambit-iPhone") that I obtained from Gambit's creator, Marc Feeley (feeley@iro.umontreal.ca). If Marc gives his permission, a future releases of libHelloGambit will include that script (or whatever replaces it).
That build creates three versions of Gambit: one each for Mac OS X, the iOS Simulator, and the iOS Device target. The examples in libHelloGambit assume that these builds of Gambit have been installed in
/usr/local/gambit/iPhoneOS /usr/local/gambit/iPhoneSimulator /usr/local/gambit/MacOSX
You can put them anywhere you like, but if you do, then the Makefiles and XCode project files in libHelloGambit will need to be adjusted to reflect the different pathnames.
BUILDING AND RUNNING
Once the appropriate versions of Gambit have been built and the Makefiles and project files have been suitably adjusted, you can build libHelloGambit from the shell by cding into the appropriate source directory and running "make". FOr example, to build the Mac OS X version of libHelloGambit, cd into <libHelloGambit>/src/macosx/libHelloGambit and run "make". The build produces a static library named libHelloGambit.a, which is used by the XCode project in <libHelloGambit>/src/macosx/Hello to build a working Cocoa application.
The Cocoa application (and the similar iOS application in the simios directory) is very simple, as is the library itself: the library exposes a single entry point, named "hello". The "hello" function accepts a C string, and passes it to a Scheme procedure that uses it to construct a simple greeting. Scheme then returns the constructed greeting string back across the FFI to C, and the test application then poses a modal dialog that dispays the greeting.
The operation of the "hello" function itself is not important; what's important is that starting up the test "Hello" application exercises the Scheme-based library in full, by calling its single exposed entry point, implemented in Scheme code, with C data as input, and then retrieving the output that was constructed by Scheme and passed back across the FFI boundary, for use in the C application.
The point of all this is to demonstrate simply how to construct a static library from Gambit Scheme sources that can be simply used in a native application built using the host platform's normal development tools.
I undertook this project because I'm working on a project that needs a common subsystem that works identically across several platforms, but which also requires a first-rate native UI on each of those platforms. Using the approach demonstrated in libHelloGambit, I can build the common data engine in Gambit Scheme (which has tremendous advantages in terms of performance, expressiveness, serialization support, and incremental development), while relying on the native development tools of each platform to deliver the UI that the platform's users expect.
I hope libHelloGambit can help other Scheme programmers more easily achieve their goals on various platforms.