I've found that there a number of pitfalls that make getting ocamlsdl up and running on Leopard a less than straightforward experience. For the record, here are a number of fixes I found I needed to apply. I'm reconstructing the process after the fact, so I apologize if anything is missing.
0. Prepare your environment
You'll need to set up some environment variables first. I'm a
tcsh user, while the default in Leopard is
bash; hence, you'll have to modify the environment yourself depending on your shell.
- Include X11 in your executable path
/usr/X11. The standard way to pass linker options is to use
freetype-config, these are in
/usr/X11/bin. Add this to your binary path.
- Fix broken Leopard linker
- Set and export
-dylib_file \ /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:\ /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
(this is one long option, broken into lines for ease of reading.)
SDL to compile
SDL proper builds and installs without problems; however, the tests need manual intervention.
- Enter the
testdirectory and ./configure.
- Then manually edit
Makefileand append $(LDFLAGS) to
- Finally make and run the tests. A good test to try is testwm.
2. Compile attendant libraries
For some strange reason,
SDL_image won't find the built-in
libpng. Build and install it, together with
libtiff. Then, build and install
SDL_mixer. Everything should work; if not, check that the variables above are correctly set in your session's environment.
I assume you're using
ocamlfind; if not, you'll probably not find trouble with the last step.
- Start by doing ./configure; it should say that it'll build
- Then, edit
makefile.config.gccso that lines 29 and 30 read -framework Cocoa instead of the original -Wl,-framework,Cocoa.
- Also, edit
src/Makefileso that line 89 reads $(RANLIB) $$($(OCAMLFIND) query sdl)/*.$(A) instead of the original $(RANLIB) $$($(OCAMLFIND) printconf destdir)/*.$(A).
- Finaly make it.
If you've installed a previous version of
ocamlsdl and you're using
ocamlfind, you'll need to manually remove the installation directory (ocamlfind query sdl) prior to sudo make install.
I've found a great "hello world"-type of walk-through., but it needs some tweaking for MacOS X, as the
ocamlsdl README explains. Use the following
RESULT = testsdl_1 SOURCES = testsdl_1.ml PACKS = bigarray sdl OCAMLBLDFLAGS = -custom include OCamlMakefile
and make sure that the example built with make nc (native code) and make (bytecode) both work. Again, I assume you're using