[HOpenGL] Compiling hopengl apps?

Hendrik Iben hiben at informatik.uni-bremen.de
Sat Jul 21 12:05:12 EDT 2007


Hugh Perkins schrieb:
> Started to play with hopengl.  It's pretty cool :-) Very easy to use, quite
> cool :-)
> 
> Started to look at perf.  What interests me most is to see how fast we can
> make vertex3f calls.  Basically, we're testing the speed of the haskell/c
> boundary, where security(?) and marshalling are going to occur.
> 
> Yes, we can send the vertices to a vertexarray and not have to handle
> vertex3f calls, but that's not what I want to measure ;-)
> 
> So, have a really rough and ready application that draws 45000 triangles a
> frame, then measures the framerate.  Thats about 150,000 calls to vertex3f
> per frame.
> 
> The application runs in Java, C#, and now Haskell.
> 
> Running in ghci, this runs at about 1.5 fps, really ballpark, havent
> checked
> I'm really drawing the number of triangles I think I'm drawing, or settings
> such as backface-culling or shademodel.  That's not too bad.
> 
> I'd like to compile to an executable to increase the framerate, but it's
> giving me the following output:
> 
> J:\dev\haskell>ghc -fglasgow-exts -O2 -o OglPerf.exe OglPerf.hs
> OglPerf.o(.text+0x1f4):ghc3668_0.hc: undefined reference to
> `glutPostRedisplay at 0
> '
> OglPerf.o(.text+0x255):ghc3668_0.hc: undefined reference to `glVertex3f at 12'
> OglPerf.o(.text+0x1148):ghc3668_0.hc: undefined reference to
> `glViewport at 16'
> OglPerf.o(.text+0x1157):ghc3668_0.hc: undefined reference to
> `glMatrixMode at 4'
> OglPerf.o(.text+0x115f):ghc3668_0.hc: undefined reference to
> `glLoadIdentity at 0'
> OglPerf.o(.text+0x11cc):ghc3668_0.hc: undefined reference to `glFrustum at 48'
> OglPerf.o(.text+0x11db):ghc3668_0.hc: undefined reference to
> `glMatrixMode at 4'
> OglPerf.o(.text+0x11e3):ghc3668_0.hc: undefined reference to
> `glLoadIdentity at 0'
> OglPerf.o(.text+0x11fd):ghc3668_0.hc: undefined reference to
> `glTranslatef at 12'
> OglPerf.o(.text+0x1672):ghc3668_0.hc: undefined reference to
> `OpenGLzm2zi2zi1_Gr
> aphicsziRenderingziOpenGLziGLziVertexSpec_Vertex3_con_info'
> OglPerf.o(.text+0x1764):ghc3668_0.hc: undefined reference to
> `OpenGLzm2zi2zi1_Gr
> aphicsziRenderingziOpenGLziGLziVertexSpec_Vertex3_con_info'
> OglPerf.o(.text+0x1856):ghc3668_0.hc: undefined reference to
> `OpenGLzm2zi2zi1_Gr
> aphicsziRenderingziOpenGLziGLziVertexSpec_Vertex3_con_info'
> OglPerf.o(.text+0x1948):ghc3668_0.hc: undefined reference to
> `OpenGLzm2zi2zi1_Gr
> aphicsziRenderingziOpenGLziGLziVertexSpec_Vertex3_con_info'
> OglPerf.o(.text+0x1b56):ghc3668_0.hc: undefined reference to
> `OpenGLzm2zi2zi1_Gr
> aphicsziRenderingziOpenGLziGLziPrimitiveMode_Quads_closure'
> OglPerf.o(.text+0x1de9):ghc3668_0.hc: undefined reference to
> `OpenGLzm2zi2zi1_Gr
> aphicsziRenderingziOpenGLziGLziFramebuffer_marshalClearBuffer_closure'
> OglPerf.o(.text+0x1e00):ghc3668_0.hc: undefined reference to
> `OpenGLzm2zi2zi1_Gr
> aphicsziRenderingziOpenGLziGLziFramebuffer_sum_closure'
> OglPerf.o(.text+0x1e42):ghc3668_0.hc: undefined reference to
> `OpenGLzm2zi2zi1_Gr
> aphicsziRenderingziOpenGLziGLziFramebuffer_sum_closure'
> [...]
> aphicsziRenderingziOpenGLziGLziStringQueries_Vendor_closure'
> OglPerf.o(.text+0x340f):ghc3668_0.hc: undefined reference to
> `OpenGLzm2zi2zi1_Gr
> aphicsziRenderingziOpenGLziGLziStringQueries_Renderer_closure'
> OglPerf.o(.text+0x3634):ghc3668_0.hc: undefined reference to
> `OpenGLzm2zi2zi1_Gr
> aphicsziRenderingziOpenGLziGLziBasicTypes_Enabled_closure'
> OglPerf.o(.text+0x3668):ghc3668_0.hc: undefined reference to
> `OpenGLzm2zi2zi1_Gr
> aphicsziRenderingziOpenGLziGLziCoordTrans_normalizze_closure'
> OglPerf.o(.text+0x36c1):ghc3668_0.hc: undefined reference to
> `OpenGLzm2zi2zi1_Gr
> aphicsziRenderingziOpenGLziGLziBasicTypes_Enabled_closure'
> OglPerf.o(.text+0x3716):ghc3668_0.hc: undefined reference to
> `OpenGLzm2zi2zi1_Gr
> aphicsziRenderingziOpenGLziGLziBasicTypes_Enabled_closure'
> OglPerf.o(.text+0x374a):ghc3668_0.hc: undefined reference to
> `OpenGLzm2zi2zi1_Gr
> aphicsziRenderingziOpenGLziGLziColors_lighting_closure'
> [...]
> collect2: ld returned 1 exit status
> 
> What am I missing?

I could image two different origins of that problem. The first one would
 be, that GHC tries to use the object files that were generated during a
previous GHCi-session and fails at the linking step. In that case you
should remove all gerated .hi and the windows-world equivalent to object
files and try again.
The second thing that comes to my mind is that you are not using the
'--make' switch and that GHC fails to recognize and link the missing
libraries. Maybe this could also be solved by adding '-package OpenGL
-package GLUT' to the compile command.
Personally I tend to use Cabal even for small projects so it takes care
of all these technical details :-)

I hope this is of some help to you.

Best regards,
Hendrik


More information about the HOpenGL mailing list