[Haskell-cafe] GHC 6.8.2 as a library on Windows and GHCi
gwern0 at gmail.com
gwern0 at gmail.com
Wed Jan 9 11:23:58 EST 2008
On 2008.01.09 17:07:46 +0100, Peter Verswyvelen <bf3 at telenet.be> scribbled 4.7K characters:
> 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
I think your installation is just buggy. I ran it here, and it compiles fine (although it doesn't run, as Linux obviously has "d:/app/ghc-6.8.2") and runs, printing "4" if I replace the string with "/usr/lib/ghc-6.8.2". Could it be that your GHCi is not the 6.8.2 one, or your path incorrect?
--
gwern
& b AHPCRC Playboy Dolch += SG530 Karimov CNCIS beef
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080109/1c425db5/attachment.bin
More information about the Haskell-Cafe
mailing list