[Haskell-cafe] Export Haskell Libraries

SevenThunders mattcbro at earthlink.net
Fri Apr 13 00:48:51 EDT 2007


I've finished a good sized Haskell project which I now must expose as a
library (along with a lot of C code) to my fellow engineers.  I had
originally devoped my code on Windows XP and managed to learn how to wrap my
Haskell code in a DLL and create an MSVC linkable library stub for the DLL. 
Although involved, the output in windows is relatively transparent in that
as long as the paths are available to the Haskell runtime libraries and my
DLL, linking is straightforward.

Now however I find I must export the same libraries to linux.  I decided to
get 'smart' and repackage my build tools using CMAKE and cabal.  Building
the C object files is no problem and even configuring Cabal to generate my
executables is not too painful.  However the pain begins when one tries to
link any Haskell object files or libraries to an external C program.  Using
ghc -v during the build reveals that gcc has about 50 -u flag arguments and
links to 9 or 10 different libraries.    Given that my little component is
just a tiny part of a large software project involving many more engineers
and many man years of work,  it's not going to be fun to link my little
library using all these crazy build flags to a large external project,
especially when order is important.  Wouldn't it be nice if there were a
single run time library I could link to, (or even generate on the fly) that
didn't have this intricate build step.  How is ghc/Haskell supposed to
integrate with the rest of the software world?

A related issue in the building of my export libraries is cabal itself.  I
want to package my own library with some external object files etc and some
Haskell code.  It's easily done with ar and the correct object files. 
Unfortunately it is not clear from the documentation how I can force cabal
to place the object files and generated stub files in a place where I can
use them.  (CMake is kind of forcing me to have them reside with the source
for reasons I don't want to go into here.)   I instead find myself copying
the object files (*.o) back into the source directory from an obscure tmp
directory several layers down from the source directory.   This is not
particularly portable and is probably quite fragile once someone decides to
change the directory hiearcharchy in cabal.

I guess I am surprised that on linux, with all of it's amazing software
development tools, that Haskell export libraries would be this tricky to
develop.


-- 
View this message in context: http://www.nabble.com/Export-Haskell-Libraries-tf3569747.html#a9972866
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list