ghci dynamic loading of X11 - unknown symbol `_printf$LDBLStub'
I have a problem with using ghci to dynamically load the X11 library on Mac OS X.
I create the following file: -- test.hs -- module Main where import Graphics.X11.Xlib main = do print "Hello, world!"
When I compile this with ghc --make test.hs, I get an executable that is properly linked and works.
With dynamic loading, there are two issues:
- A minor issue (easy workaround): When I try to load this with ghci, i.e.
$ ghci test.hs [... ascii graphics ...] Loading package base ... linking ... done. Ok, modules loaded: Main. Prelude Main> main Loading package X11-1.1 ... can't load .so/.DLL for: X11 (dlopen(libX11.dylib, 10): image not found)
I can fix this by running ghci setting DYLD_LIBRARY_PATH=/usr/X11R6/lib, which is where the Apple X11 lives.
- Maybe a more serious issue?
$ DYLD_LIBRARY_PATH=/usr/X11R6/lib ghci test.hs
[... ascii graphics ...]
Loading package base ... linking ... done.
Ok, modules loaded: Main.
Prelude Main> main
Loading package X11-1.1 ... linking ... <interactive>:
/opt/local/lib/ghc-6.6/HSX11_cbits.o: unknown symbol
_printf$LDBLStub' ghc-6.6: unable to load packageX11-1.1'
Issue (1) is probably trivial, I am only pointing it out in case it is related to issue (2).
When I pointed this out on darcs-users, there were some suggestion that this might be due to SystemStubs not being linked in, or some problem with the compiler - apparently X11 is meant to be compiled with gcc 3.3, and it should work if compiled with gcc 4 as long as SystemStubs is linked in (?).
I have replicated this with the following combinations of software and hardware: Mac OS X 10.4.8, dual G5, Xcode 2.4.1 (gcc 4.0.1), Apple X11 1.1.3, macports ghc 6.6_1
Mac OS X 10.4.8, dual G5, Xcode 2.3 (gcc 4.0.1), Apple X11 1.1.2, macports ghc 6.6_1
Mac OS X 10.4.8, dual G5, Xcode 2.3 (gcc 4.0.1), Apple X11 1.1.2, binary distribution of ghc 6.6 for Mac OS X.
Mac OS X 10.4.8, G4 (Powerbook), Xcode 2.3 (gcc 4.0.1), Apple X11 1.1.2, macports ghc 6.6_1