[Haskell-cafe] Linker errors to OpenGL with GHC 6.10.1
p3k at iki.fi
Thu Nov 13 02:18:21 EST 2008
2008/11/13 Greg Fitzgerald <garious at gmail.com>:
> Do you know how I can fix these linker errors?
> C:\projects\fun>cat HelloWorld.hs
> import Graphics.Rendering.OpenGL
> import Graphics.UI.GLUT
> main = do
> (progname, _) <- getArgsAndInitialize
> createWindow "Hello World"
> displayCallback $= clear [ColorBuffer]
> C:\projects\fun>ls lib
> C:\projects\fun>ghc -Llib -lglut32 -lglu32 -lopengl32 HelloWorld.hs --make
> Linking HelloWorld.exe ...
> undefined reference to `glutGet'
I'm assuming this is on Windows because of C:\...
These kinds of linker errors happened to me when I built libHSGLUT
with a wrong type of calling convention (by accident). There are two
callconvs, and they are called stdcall and ccall on the Haskell side.
The 'runhaskell setup configure' step is supposed to detect the
correct one to use, so you should run it and then grep for lines with
CALLCONV. They should say stdcall on Windows. If you find them saying
ccall, that's likely the cause of all the linker errors. (Most Windows
dynamic libraries use stdcall, but for extra configuration fun OpenAL
If this is the problem, you can change the offending ccall in the
configuration files to stdcall and rebuild the library. Grepping for
CALLCONV will also show the places you need to change this way.
In my case the wrong configuration came from using the sh program from
Cygwin. With the MSYS variety there was no problem. To be exact, it
came down to the $host variable checked by the configuration script.
More information about the Haskell-Cafe