Re: Win32 GHC cannot link GLUT

Sven Panne <[email protected]>
Newsgroups gmane.comp.lang.haskell.hopengl
Message-ID <[email protected]>
Manuel Garcia Rodriguez wrote:
> [...]
> import Graphics.UI.GLUT
> import Graphics.Rendering.OpenGL

Small note: Importing Graphics.UI.GLUT is enough, it re-exports everything from
Graphics.Rendering.OpenGL.

> [...]
> H:\Documents and Settings\manuel>ghc -package GLUT -o HelloWindow HelloWindow.hs

Another small note: GLUT and OpenGL are "auto" packages, i.e. an explicit
"-package GLUT" is only necessary for this kind of one-shot compilation/linking,
not when using "--make" or ghci:

    ghc --make -o HelloWindow HelloWindow.hs

Or even

    ghc --make HelloWindow.hs

resulting in an executable named "a.out". We are all lazy...   :-)

> [...]
> H:/ghc/ghc-6.2/HSGLUT.o: unknown symbol `_glutMainLoop'
> ghc.exe: panic! (the `impossible' happened, GHC version 6.2):
>         can't load package `GLUT'

Ooops, something went wrong during building and/or packaging the .msi file,
the glut32 library is missing in the linking step. This results in your
problem with ghci and the linking problem with ghc. But this can easily be
fixed by manually editing the package.conf file (probably located at
H:/ghc/ghc-6.2/package.conf at your site): Find the package description
for GLUT (name = "GLUT",) look for the next line containing

    extra_ld_opts = [],

and change it to

    extra_ld_opts = ["-lglut32"]

Hope that helps,
    S.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.