[HOpenGL] bug in package.conf (ghci -package OpenGL / ghci -package GLUT)

Glynn Clements glynn.clements at virgin.net
Tue Dec 30 09:00:26 EST 2003


Marc A. Ziegert wrote:

> there still exist systems/programs that need a strict sequence of .so
> files to link. i.e. at least ghci on i386-gnu-linux.

> problem to link GLU, because GL has not been linked before.
> it happens in the package OpenGL, because it is in the package_deps of GLUT.
> 
> GLUT's libraries would have the same problem, but --because of
> package_deps-- GL and GLU must have been linked before. unnecessary to
> link them again.
> 
> it is:
> 
>  Package
>     {name = "OpenGL",
>      package_deps = ["base"],
>      extra_ld_opts =
>        ["-lGLU",
> 	"-lGL",
>  Package
>     {name = "GLUT",
>      package_deps = ["base", "OpenGL"],
>      extra_ld_opts =
>        ["-lglut",
> 	"-lGLU",
> 	"-lGL",
> 
> and should be:
> 
>  Package
>     {name = "OpenGL",
>      package_deps = ["base"],
>      extra_ld_opts =
>        ["-lGL",
> 	"-lGLU",
>  Package
>     {name = "GLUT",
>      package_deps = ["base", "OpenGL"],
>      extra_ld_opts =
>        [	"-lglut",

I don't know how ghc/ghci use this information internally, but the
ordering will differ depending upon whether you're trying to:

a) generate an executable with the linker, or
b) load shared libraries with dlopen().

For case a), dependencies should come after the library which depends
upon them in the link command (although this is more likely to matter
for static libraries than for shared libraries). For case b) the
dependencies must have been loaded with dlopen(..., RTLD_GLOBAL) prior
to loading the library which depends upon them.

However, this is only an issue for shared libraries which are built
without dependency information (AFAIK, ghci can't use static
libraries). If the libraries are built correctly, you only need to
explicitly load libglut, and everything else (GLU/GL/X11) will get
pulled in automatically.

Unfortunately, the stock GLUT Imakefiles don't add libGL or libGLU as
dependencies (but they *do* add the X11 libraries). If your GLUT
library came from a vendor-supplied package, try to persuade your
vendor to fix this in their version.

-- 
Glynn Clements <glynn.clements at virgin.net>


More information about the HOpenGL mailing list