The "impossible" has happened ...

David Duke D.Duke at bath.ac.uk
Thu Jan 22 10:19:03 EST 2004


Hello,

I am an "occasional" user of Haskell (who knows, that may change...) but
recently installed GHC 6.2 and was trying to explore the graphics 
support.  To test my understanding I modified a simple example from Sven 
Panne's  HOpenGL library (file Hi.hs, attached) to make it compatible 
with the GHC OpenGL support.  I can load this under ghci, but when I try 
to execute I get the following error message, which prompted this email:

-----------------------------------------------------
Prelude> :cd HOpenGL-1.05\examples\redbook_HS
Prelude> :load Hi
Skipping  Main             ( Hi.hs, Hi.o )
Ok, modules loaded: Main.
Prelude Main> main
Loading package OpenGL ... linking ... done.
Loading package GLUT ... linking ...
C:/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 at haskell.org,
or http://sourceforge.net/projects/ghc/.

Prelude Main>
-----------------------------------------------------


If I try compiling directly using ghc, I get a load of "undefined 
references" -- again suggesting that the compiler isn't finding the glut 
library.  I'm using the Windows binary package, ghc-6-2-1.msi, running 
under XP.  I've been able to compile and run simple programs both from 
the ghci shell and from cygwin, so the basic installation seems fine. 
The install directory (c:/ghc/ghc-6.2/) clearly contains the OpenGL 
libraries (which does seem to be found) and the GLUT library, both the 
archive libHSGLUT.a and the library linkable HSGLUT.o.

I may have made a basic error, but any suggestions?  Please mailto or Cc 
me as I am not on the list.

thanks,
David


-- 
Dr. David Duke                        Email: D.Duke at bath.ac.uk
Department of Computer Science        Web:   www.bath.ac.uk/~masdad/
University of Bath                    Tel:   +44 1225 383 407
Bath, BA2 7AY U.K.                    Fax:   +44 1225 383 493

-------------- next part --------------
{-
   Hello.hs (adapted from hello.c which is (c) Silicon Graphics, Inc)
   This file is part of HOpenGL - a binding of OpenGL and GLUT for Haskell.
   Copyright (C) 2000  Sven Panne <Sven.Panne at informatik.uni-muenchen.de>

   This is a simple, introductory OpenGL program.
-}

import Graphics.Rendering.OpenGL.GL
import Graphics.UI.GLUT

display :: DisplayCallback
display = do
   -- clear all pixels
   clear [ColorBuffer]

   -- draw white polygon (rectangle) with corners at
   -- (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
   color (Color3 1.0 1.0 1.0 :: Color3 GLfloat)
   renderPrimitive Polygon $ mapM_ vertex [
      Vertex3 0.25 0.25 0.0,
      Vertex3 0.75 0.25 0.0,
      Vertex3 0.75 0.75 0.0,
      Vertex3 0.25 0.75 (0.0 :: GLfloat)]

   -- don't wait!
   -- start processing buffered OpenGL routines
   flush

myInit :: IO () 
myInit = do
   -- select clearing color
   clearColor $= (Color4 0.0 0.0 0.0 0.0)

   -- initialize viewing values
   matrixMode $= Projection
   loadIdentity
   ortho 0.0 1.0 0.0 1.0 (-1.0) 1.0

{-
   Declare initial window size, position, and display mode
   (single buffer and RGBA).  Open window with "hello"
   in its title bar.  Call initialization routines.
   Register callback function to display graphics.
   Enter main loop and process events.
-}
main :: IO ()
main = do
   getArgsAndInitialize
   initialDisplayMode $= [ SingleBuffered, RGBMode ]
   initialWindowSize $= (Size 250 250)
   initialWindowPosition $= (Position 100 100)
   createWindow "hello"
   myInit
   displayCallback $= display
   mainLoop



More information about the Glasgow-haskell-bugs mailing list