Win32 GHC cannot link GLUT

Hi. I've installed GHC 6.2, but trying to compile a simple HelloWindow.hs program fails. The same code runs with Hugs. Both installs are lastest .msi import Graphics.UI.GLUT import Graphics.Rendering.OpenGL main = do getArgsAndInitialize createAWindow "Hello Window" mainLoop createAWindow windowName = do createWindow windowName displayCallback $= clear [ColorBuffer] H:\Documents and Settings\manuel>ghc -package GLUT -o HelloWindow HelloWindow.hs compilation IS NOT required H:/ghc/ghc-6.2/libHSGLUT.a(Window__53.o)(.text+0x85):ghc14736.hc: undefined reference to `glutCreateWindow@4' H:/ghc/ghc-6.2/libHSGLUT.a(Registration__78.o)(.text+0x3ec):ghc10876.hc: undefined reference to `glutGetWindow@0' H:/ghc/ghc-6.2/libHSGLUT.a(Window__10.o)(.text+0x63):ghc11416.hc: undefined reference to `glutDisplayFunc@4' H:/ghc/ghc-6.2/libHSGLUT.a(Initialization__158.o)(.text+0x123):ghc16024.hc: undefined reference to `glutInit@8' H:/ghc/ghc-6.2/libHSGLUT.a(Begin__2.o)(.text+0x54):ghc15656.hc: undefined reference to `glutMainLoop@0' H:/ghc/ghc-6.2/libHSGLUT.a(Registration__38.o)(.text+0x69):ghc10876.hc: undefined reference to `glutTimerFunc@12' H:\Documents and Settings\manuel>ghci HelloWindow.hs ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.2, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Loading package base ... linking ... done. Skipping Main ( HelloWindow.hs, HelloWindow.o ) Ok, modules loaded: Main. Prelude Main> main Loading package OpenGL ... linking ... done. Loading package GLUT ... linking ... 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' Please report it as a compiler bug to glasgow-haskell-bugs@haskell.org, or http://sourceforge.net/projects/ghc/. Thanks. _______________________________________________________________ Yahoo! Sorteos ¡Ya puedes comprar Lotería de Navidad! http://yahoo.ventura24.es/

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.
participants (2)
-
Manuel Garcia Rodriguez
-
Sven Panne