What to do when GHC works, RUNGHC fails

I'm experimenting creating a Cabal script on Windows that installs a module that refers to some DLLs (freetype, png, ...) via C wrappers When configuring, building, and installing using cabal, a test program that uses this installed module runs fine when compiled with GHC --make, but fails miserably when run with RUNGHC (or GHCi) The first thing I noticed is that RUNGHC looks for a DLL called "png.dll" (which it doesn't find and then bails out with an error), while the executable build with GHC uses the correct "libpng3.dll". When I rename the libpng3.dll into png.dll, RUNGHC goes a bit further but then fails with an "unknown symbol". Obviously I did something wrong in my Cabal script, but I have no idea what it is. There seems to be a big difference when it comes to linking between of GHCi and GHC . Any guidelines on what to do in cases like the one above? I really like to use the interpreter because it provides much shorter turnaround times, and things like this stop me from using it. Thanks, Peter

2008/5/22 Peter Verswyvelen
The first thing I noticed is that RUNGHC looks for a DLL called "png.dll" (which it doesn't find and then bails out with an error), while the executable build with GHC uses the correct "libpng3.dll". When I rename the libpng3.dll into png.dll, RUNGHC goes a bit further but then fails with an "unknown symbol". Obviously I did something wrong in my Cabal script, but I have no idea what it is.
There seems to be a big difference when it comes to linking between of GHCi and GHC . Any guidelines on what to do in cases like the one above?
We had a similar problem with Takusen and ghci on Windows, where the PostgreSQL client dll is called libpq.dll, rather than pq.dll. We also solved it by copying pq.dll to libpq.dll. The extra-libs option is pq, rather than libpq. That fixed it for us, so I don't know why yours is still failing. Perhaps you can post a link to the src? Alistair

So it seems the GHCi linker is not using the metadata in the library file correctly? The libpng.dll.a library file clearly contains a reference to libpng3.dll, and I guess since GHC is using the GCC linker, this works fine, but GHCi most likely has its own linker? If this is correct, we should file a bug report?
-----Original Message----- From: abayley@gmail.com [mailto:abayley@gmail.com] On Behalf Of Alistair Bayley Sent: Friday, May 23, 2008 10:08 AM To: Peter Verswyvelen Cc: Haskell-Cafe Subject: Re: [Haskell-cafe] What to do when GHC works, RUNGHC fails
2008/5/22 Peter Verswyvelen
: The first thing I noticed is that RUNGHC looks for a DLL called "png.dll" (which it doesn't find and then bails out with an error), while the executable build with GHC uses the correct "libpng3.dll". When I rename the libpng3.dll into png.dll, RUNGHC goes a bit further but then fails with an "unknown symbol". Obviously I did something wrong in my Cabal script, but I have no idea what it is.
There seems to be a big difference when it comes to linking between of GHCi and GHC . Any guidelines on what to do in cases like the one above?
We had a similar problem with Takusen and ghci on Windows, where the PostgreSQL client dll is called libpq.dll, rather than pq.dll. We also solved it by copying pq.dll to libpq.dll. The extra-libs option is pq, rather than libpq. That fixed it for us, so I don't know why yours is still failing. Perhaps you can post a link to the src?
Alistair
-- No virus found in this incoming message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.21/1457 - Release Date: 5/20/2008 4:45 PM

2008/5/23 Peter Verswyvelen
So it seems the GHCi linker is not using the metadata in the library file correctly? The libpng.dll.a library file clearly contains a reference to libpng3.dll, and I guess since GHC is using the GCC linker, this works fine, but GHCi most likely has its own linker?
If this is correct, we should file a bug report?
This seems to be the same bug: http://hackage.haskell.org/trac/ghc/ticket/1883 The ghci linker is a custom one (AFAIK) and is "different" from GNU ld. That's a feature, not a bug :-) GNU ld, for example, can find either of libxxx.dll or xxx.dll if you say -lxxx. See this ticket for another difference between ghci and GNU ld (ghci's linker tries to link _all_ symbols in the library archive, rather than just the modules that you're using): http://hackage.haskell.org/trac/ghc/ticket/1477 Alistair
participants (2)
-
Alistair Bayley
-
Peter Verswyvelen