It looks like libSystem defines bzero. [localhost:/usr/lib] burton% nm -o libSystem* | grep bzero | grep T libSystem.B.dylib:bzero.o:70004bd0 T _bzero libSystem.B_debug.dylib:bzero.o:48da6160 T _bzero libSystem.B_profile.dylib:bzero.o:48da5010 T _bzero libSystem.dylib:bzero.o:70004bd0 T _bzero libSystem_debug.dylib:bzero.o:48da6160 T _bzero libSystem_profile.dylib:bzero.o:48da5010 T _bzero [localhost:/usr/lib] burton% When I make the changes Johan suggests, I get exactly the same problem:
Hi Alastair,
I've gotten a bit further, I think.
After replacing "-shared" with "-bundle", and setting "LD" to "cc" (which are the RIGHT values, and actually mentioned in the distributed ffi documentation -- blush!), the process fails at load time:
Reading file "X.hs": ERROR "X.hs":3853 - Unknown primitive reference "prim_X_fontRightToLeft"
However, running
nm X.so | grep fontRightToLeft
gives
0001408c t _prim_X_fontRightToLeft
That is, we seem to have run into the leading underscore problem you mentioned.
I don't have GreenCard installed, so I can't regenerate X.c the proper way. Is there a better way of making a MacOS X compatible distribution than requiring the user to run GreenCard?
-- Johan
My edited Makefile is as follows (so everybody is clear on what everybody else is doing): ############################################################################## # Makefile for Xlib with Hugs on Unix # # This makefile is for GNU Make ver. 3.76 or later. ############################################################################## ################################################################ # Configuration parameters. These may need slight modification. # # Rather than edit this file, you can override the settings when you # invoke Make. For example: # # make system=SunOS X_dir=/usr/local/X11R6 # ################################################################ # What OS are we using? Affects choice of linker flags. # Possible values: Linux, FreeBSD, NetBSD, SunOS and Unixlike # FWB changed # system=Linux # to system=FreeBSD # FWB end # Which directory contains lib/libX11.a and include/X11/X.h? X_dir=/usr/X11R6 # Which directory is Hugs installed in? # FWB changed # hugs_install=/usr/share/hugs # to hugs_install=/usr/local/share/hugs # FWB end # hugs_install=$(HOME)/local/share/hugs # Should we rerun GreenCard if GreenCard generated files are out of date? # (This will usually be set to "no" in distributions and "yes" in # development copies.) rerun_GC=no ################################################################ # Tools and how to run them. Nothing below this line should # need modified. ################################################################ SHELL = /bin/sh RM = rm -f # At least Sun's Workshop C Compiler 5.0 98/12/15 C 5.0 has trouble with # some of the generated C code. Insist on gcc for now. # FWB changed # CC = gcc # to CC = cc # FWB end INCLUDES = -I$(X_dir)/include -I$(hugs_install)/include # FWB changed # LD = ld # to LD = cc # and # LDFLAGS += -L$(X_dir)/lib -lX11 # to LDFLAGS += -L$(X_dir)/lib -lX11 -lSystem # FWB end # The following choices have been found to be appropriate for building # shared object files on various systems. # Please let us know if these don't work or if you know the appropriate # choice for other systems. LDFLAGS_MKSO.Linux = -shared # FWB changed # LDFLAGS_MKSO.FreeBSD = -shared # to LDFLAGS_MKSO.FreeBSD = -bundle # FWB end LDFLAGS_MKSO.NetBSD = -shared LDFLAGS_MKSO.SunOS = -G LDFLAGS_MKSO.Unixlike = -shared LDFLAGS_MKSO = $(LDFLAGS_MKSO.$(system)) GC = green-card GC_OPTS = --target=hugs ################################################################ # Implicit rules for GreenCard and shared objects ################################################################ ifeq ($(rerun_GC),yes) %.c %.hs: %.gc $(GC) $(GC_OPTS) $< endif %.o: %.c $(CC) -c $(CPPFLAGS) $(INCLUDES) $(CFLAGS) $< -o $@ %.so: %.o $(LD) $(LDFLAGS_MKSO) $(LDFLAGS) $^ -o $@ ################################################################ # Source and object files ################################################################ gc_sources = $(wildcard *.gc) c_sources = $(wildcard cbits/*.c) hs_gen_sources = $(gc_sources:.gc=.hs) all_hs_sources = $(hs_sources) $(hs_gen_sources) c_gen_sources = $(gc_sources:.gc=.c) all_c_sources = $(c_sources) $(c_gen_sources) all_c_objects = $(all_c_sources:.c=.o) shared_objects = $(gc_sources:.gc=.so) ################################################################ # Main targets ################################################################ .PHONY: all all: $(hs_gen_sources) $(shared_objects) ifeq ($(rerun_GC),yes) clean:: $(RM) $(hs_gen_sources) $(RM) $(c_gen_sources) endif clean:: $(RM) $(all_c_objects) $(RM) $(shared_objects) ################################################################ # Auxiliary targets ################################################################ .PRECIOUS: $(hs_gen_sources) $(shared_objects) .INTERMEDIATE: cbits/auxiliaries.o # Additional dependences. Xlib.so : cbits/auxiliaries.o Xlib.o X.o : cbits/HsXlib.h ################################################################ # End ################################################################