[Haskell-cafe] GHC 6.8.2 as a library on Windows and GHCi

Peter Verswyvelen bf3 at telenet.be
Wed Jan 9 11:07:46 EST 2008


I while I ago I sent an email regarding hs-plugins not working on windows.

I now tried to directly use GHC API, but I also failed.

The following program (which might be buggy, I copy/pasted from various 
sources)

import DynFlags
import GHC

main = defaultErrorHandler defaultDynFlags $ do
  session <- newSession (Just "d:/app/ghc-6.8.2")
  flags <- getSessionDynFlags session
  (flags, _) <- parseDynamicFlags flags []
  GHC.defaultCleanupHandler flags $ do
    setSessionDynFlags session flags{ hscTarget=HscInterpreted }
    prelude <- findModule session (mkModuleName "Prelude") Nothing
    setContext session [] [prelude]
    runStmt session "let n = 2 + 2" RunToCompletion -- n is bound
    runStmt session "n"  RunToCompletion            -- 4 is printed 
(note "it" is bound)


gives the following error when run from GHCi

*Main> :load "l:/test.hs"
[1 of 1] Compiling Main             ( l:/test.hs, interpreted )
Ok, modules loaded: Main.
*Main> main

GHCi runtime linker: fatal error: I found a duplicate definition for symbol
   _forkOS_entry
whilst processing object file
   d:/app/ghc-6.8.2/lib\base-3.0.1.0/HSbase-3.0.1.0.o
This could be caused by:
   * Loading two different object files which export the same symbol
   * Specifying the same object file twice on the GHCi command line
   * An incorrect `package.conf' entry, causing some object to be
     loaded twice.
GHCi cannot safely continue in this situation.  Exiting now.  Sorry.


Process haskell finished

Is my code incorrect, or is this a (known?) bug in GHC 6.8.2 on Windows? 
I haven't tried the Linux version yet.

NOTE: The program *does* run fine when compiling via GHC --make.

Thanks,
Peter


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080109/744f9a88/attachment.htm


More information about the Haskell-Cafe mailing list