Graphics with XDarwin on Mac OS X

Johan Nordlander nordland@cs.chalmers.se
Tue, 11 Jun 2002 09:47:49 +0200


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


On Monday, June 10, 2002, at 06:58 , Alastair Reid wrote:

>
>> I made a quick attempt at installing the graphics library with MacOS X
>> in preparation for the Dec-2001 Hugs release, but I wasn't able to get
>> past some DLL related problems.  This is were I stopped:
>>
>>    ERROR "lib/x11/Xlib_StdDIS.hs" - Error while importing DLL
>>    "/Users/nordland/src/graphics-2.0.4/lib/x11/Xlib_StdDIS.so":
>>    Not an recognisable object file
>>
>> BTW, getting this far requires replacing "-shared" with "-dynamic",
>> and "ld" with "libtools" in the Makefile, as well as adding "-lSystem"
>> to the definition of LDFLAGS.
>
> One of two things is (I think) going on:
>
> 1) The generated .so file is invalid.
>
>    My memory of libtools is that it acts in quite a different way from
>    ld -r and friends.  It could be that the result isn't quite
>    compatible with dlopen and friends.  Or it could be that the way you
>    invoke libtools should be very different from ld.
>
> 2) The .so filename is invalid.
>
>    This is entirely possible.  IIRC, the object files generated by
>    GreenCard are technically object files not shared object files
>    so their name should end in .o not .so.  (The reason for this
>    confusion is that the fact that you use the -shared flag 
> when building
>    these files fooled me into thinking I was building a shared object
>    file.  Someone later told me I was wrong.)
>
>    Or, maybe Mac OS X uses a different file suffix for object files
>    (e.g., .dll) or doesn't use a file suffix at all?
>    If so, it's possible that libtool might do the right thing if
>    invoked right but that the current Makefile overrides this correct
>    behaviour?
>
> --
> Alastair Reid        reid@cs.utah.edu        
> http://www.cs.utah.edu/~reid/
>