[Haskell-cafe] Linkage errors in scenegraph

Gregory D. Weber gdweber at indiana.edu
Sat May 16 19:07:55 EDT 2009


I'd like to get the scenegraph package
(http://hackage.haskell.org/cgi-bin/hackage-scripts/package/scenegraph)
to work, but am encountering linkage errors.

I installed scenegraph 0.1.0.1 for ghc-6.10.1 on Fedora 10 Linux.
# runghc Setup configure --prefix=/opt
# runghc Setup build
# runghc Setup install

Then I created this little program based on the example at
http://www.haskell.org/haskellwiki/SceneGraph
(in file SGTest.hs):

module Main where

import Graphics.SceneGraph
import Control.Monad.Identity

main :: IO ()
main = runScene $ osgt $ myScene

myScene :: OSGT Identity SceneNode
myScene = 
  cube 0.5 `colour` Green
           `scale` v1x 40
           `translate` vy 2
  <+> camera `translate` vy (-10)
  <+> light `translate` vz 10

Then I compiled it and got a long list of linker errors;
here are the first few lines:

ghc --make SGTest
Linking SGTest ...
/opt/lib/scenegraph-0.1.0.1/ghc-6.10.1/libHSscenegraph-0.1.0.1.a(Basic__210.o): In function `sdE1_info':
(.text+0x8d): undefined reference to `scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_translateM_closure'
/opt/lib/scenegraph-0.1.0.1/ghc-6.10.1/libHSscenegraph-0.1.0.1.a(Basic__210.o): In function `scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziBasic_translate_srt':
(.data+0x0): undefined reference to `scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_translateM_closure'
/opt/lib/scenegraph-0.1.0.1/ghc-6.10.1/libHSscenegraph-0.1.0.1.a(Basic__207.o): In function `sdDq_info':
(.text+0x7e): undefined reference to `scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_scaleM_info'
/opt/lib/scenegraph-0.1.0.1/ghc-6.10.1/libHSscenegraph-0.1.0.1.a(Basic__207.o): In function `scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziBasic_scale_srt':
(.data+0x0): undefined reference to `scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_scaleM_closure'
/opt/lib/scenegraph-0.1.0.1/ghc-6.10.1/libHSscenegraph-0.1.0.1.a(Basic__491.o):(.text+0x27): undefined reference to `__stginit_scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziUtils_'

Also with this command, same result but a lot more detail:
ghc --make -v -package scenegraph SGTest

With -v, the output includes

gcc -v -o SGTest -DDONT_WANT_WIN32_DLL_SUPPORT SGTest.o 
  -L/opt/lib/scenegraph-0.1.0.1/ghc-6.10.1 
  -L/opt/lib/hmatrix-0.5.1.1/ghc-6.10.1 
  -L/opt/lib/storable-complex-0.2/ghc-6.10.1 
  ...
   -lHSscenegraph-0.1.0.1 
   -lHShmatrix-0.5.1.1 
   -lgsl -llapack -lHSstorable-complex-0.2 -lHSQuickCheck-1.2.0.0 
  ...

which seems to show that the proper -L and -l options are included.

If I'm decoding the first "undefined reference" symbol --

(.text+0x8d): undefined reference to `scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_translateM_closure'

-- correctly, then the missing symbol is in the scenegraph-0.1.0.1 package,
in module Graphics.SceneGraph.Matrix, and is associated with the translateM
function defined in that module.

I looked for this symbol with nm:

# pwd
/opt/lib/scenegraph-0.1.0.1/ghc-6.10.1
# nm HSscenegraph-0.1.0.1.o | grep translateM
         U scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_translateM_closure
         U scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_translateM_info
# nm libHSscenegraph-0.1.0.1.a | grep translateM
         U scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_translateM_closure
         U scenegraphzm0zi1zi0zi1_GraphicsziSceneGraphziMatrix_translateM_info

but I understand the "U" means that it is referenced by some other
function in these files, but is undefined in them.

Since the module Graphics.SceneGraph.Matrix does not declare any exports,
I thought that might be the reason the symbol was undefined.  But
looking back at the Haskell 98 language definition, I found that
the absence of an export declaration in a module means that
all the symbols of the module are exported.

Also, I notice that in the cabal file for scenegraph, the 
list of exposed modules

Exposed-Modules: Graphics.SceneGraph,
	Graphics.SceneGraph.Basic,
        Graphics.SceneGraph.Vector,
        Graphics.SceneGraph.Render,
        Graphics.SceneGraph.SimpleViewport,
	Graphics.SceneGraph.GraphViz,
        Graphics.SceneGraph.Library,
        Graphics.SceneGraph.Dump,
        Graphics.SceneGraph.Textures

does not include Graphics.SceneGraph.Matrix, but that should only mean
that I can't call functions of that module directly -- not that the
other SceneGraph modules can't call them -- right?

So, why is this symbol undefined?  And how can I get it to work?

Oh by the way: I can actually use this package if I move into its
src directory, add a main function to Examples.hs, and compile
and run it right there.  Just can't use it as an installed library,
it seems.


-- 
   ___   ___  __     _      
  / _ \ / _ \| |    | |     Gregory D. Weber, Associate Professor
 / /_\// / | | | /\ | |     Indiana University East
/ /_\\/ /__| | |/  \| |     http://mypage.iu.edu/~gdweber/
\____/\_____/\___/\__/      Tel. (765) 973-8420; FAX (765) 973-8550


More information about the Haskell-Cafe mailing list