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

there still exist systems/programs that need a strict sequence of .so files to link. i.e. at least ghci on i386-gnu-linux. coeus@titan ~ $ ghci -package GLUT ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.2, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Loading package base ... linking ... done. Loading package OpenGL ... ghc-6.2: can't load .so/.DLL for: GLU (/usr/lib/libGL U.so: undefined symbol: glPixelStorei) coeus@titan ~ $ 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",

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

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.
*sigh* This kind of problem pops up again and again...
it happens in the package OpenGL, because it is in the package_deps of GLUT.
Correct.
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.
Things are not that easy: Hugs uses the same repository for the hierarchical libraries, and it doesn't have a notion of "package" (yet). So the linker options for every package must be "self contained", otherwise building Hugs would fail. Apart from that, a repetition should not hurt.
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",
While I'm writing this mail, Glynn explains what your problem is (your GLUT is broken). What is the output of "objdump -p" on the dynamic libraries for GLUT/GLU/GL on your system and what platform are you using exactly? On my SuSE 8.2 x86 Linux system, libglut.so.3.7 depends on libGLU.so.1, which in turn depends on libGL.so.1. With this info, dlopen() with the RTLD_GLOBAL can handle the dependencies automatically, regardless of the order of libraries in extra_ld_opts. For static linking, the order given above is *necessary* for some platforms, e.g. some Solaris versions, IIRC. If library A depends on library B, A must come before B on the linker commandline, full stop. Some platforms/linkers have relaxed this condition, but for maximum portability it must stay this way. Locally you can change your package.conf, of course, but I would recommend testing both ghc with static linking and ghci. I've never imagined that the configuration handling for GLUT/GLU/GL would be so complicated: There are broken/incomplete/missing headers at various funny locations, broken libraries, differing calling conventions, etc. :-[ Cheers, S.

hm, thanks. learned something about dynamic libs. what is the ghc option to link statically? ghc -static --make Main.hs works perfectly with GLU GL in package.conf. -dynamic does not. (didn't read about it in the manual, just guessing.) coeus@titan ~/Documents/haskell/hopengl/62/callbacks $ ghc -dynamic --make Main.hs Chasing modules from: Main.hs Skipping GlutInterface ( ./GlutInterface.hs, ./GlutInterface.o ) Skipping Display ( ./Display.hs, ./Display.o ) Skipping Main ( Main.hs, Main.o ) Linking ... gcc: /usr/lib/ghc-6.2/Main.dll_o: Datei oder Verzeichnis nicht gefunden gcc: /usr/lib/ghc-6.2/PrelMain.dll_o: Datei oder Verzeichnis nicht gefunden coeus@titan ~/Documents/haskell/hopengl/62/callbacks i've got a P4-1.3GHz ( Dell :( ) gentoo linux x11-base/xfree-4.3.0-r2 media-libs/glut-3.7.1 ATI-Radeon 9500pro ati-drivers from ati homepage: http://www2.ati.com/drivers/linux/fglrx-glc22-4.3.0-3.2.8.i586.rpm (timestamp=2003-11-24) - Marc coeus@titan ~ $ l /usr/lib/libGL* lrwxrwxrwx 1 root root 38 2003-11-25 23:51 /usr/lib/libGL.so -> /usr/lib/opengl/xfree/lib/libGL.so.1.2* lrwxrwxrwx 1 root root 38 2003-11-25 23:51 /usr/lib/libGL.so.1 -> /usr/lib/opengl/xfree/lib/libGL.so.1.2* -rw-r--r-- 1 root root 689588 2003-10-22 17:06 /usr/lib/libGLU.a -rw-r--r-- 1 root root 769 2003-10-22 17:06 /usr/lib/libGLU.la lrwxrwxrwx 1 root root 13 2003-10-22 17:06 /usr/lib/libGLU.so -> libGLU.so.1.3* lrwxrwxrwx 1 root root 13 2003-10-22 17:06 /usr/lib/libGLU.so.1 -> libGLU.so.1.3* -rwxr-xr-x 1 root root 597801 2003-10-22 17:06 /usr/lib/libGLU.so.1.3* coeus@titan ~ $ l /usr/lib/libglut* -rw-r--r-- 1 root root 736 2003-10-14 19:27 /usr/lib/libglut.la lrwxrwxrwx 1 root root 16 2003-10-14 19:27 /usr/lib/libglut.so -> libglut.so.3.7.1* lrwxrwxrwx 1 root root 16 2003-10-14 19:27 /usr/lib/libglut.so.3 -> libglut.so.3.7.1* -rwxr-xr-x 1 root root 306255 2003-10-14 19:27 /usr/lib/libglut.so.3.7.1* coeus@titan ~ $ qpkg -f /usr/lib/libGLU.so x11-base/xfree * coeus@titan ~ $ qpkg -f /usr/lib/libglut.so media-libs/glut * coeus@titan ~ $ cat /usr/lib/libGLU.la # libGLU.la - a libtool library file # Generated by ltmain.sh - GNU libtool 1.4 (1.920 2001/04/24 23:26:18) # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='libGLU.so.1' # Names of this library. library_names='libGLU.so.1.3 libGLU.so.1 libGLU.so' # The name of the static archive. old_library='' # Libraries that this one depends upon. dependency_libs=' -L/usr/lib -L/usr/X11R6/lib -lGL -lSM -lICE -lXmu -lXt -lXext -lXi -lX11 -ldl -lpthread ' # Version information for libGLU. current=4 age=3 revision=0 # Is this an already installed library? installed=yes # Files to dlopen/dlpreopen dlopen='' dlpreopen='' # Directory that this library needs to be installed in: libdir='/usr/lib' coeus@titan ~ $ cat /usr/lib/libglut.la # libglut.la - a libtool library file # Generated by ltmain.sh - GNU libtool 1.4 (1.920 2001/04/24 23:26:18) # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='libglut.so.3' # Names of this library. library_names='libglut.so.3.7.1 libglut.so.3 libglut.so' # The name of the static archive. old_library='' # Libraries that this one depends upon. dependency_libs=' -L/usr/X11R6/lib -lSM -lICE -lXmu -lXext -lXi -lX11' # Version information for libglut. current=10 age=7 revision=1 # Is this an already installed library? installed=yes # Files to dlopen/dlpreopen dlopen='' dlpreopen='' # Directory that this library needs to be installed in: libdir='/usr/lib' coeus@titan ~ $ objdump -p /usr/lib/libGLU.so /usr/lib/libGLU.so: file format elf32-i386 Program Header: LOAD off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**12 filesz 0x0007eb9f memsz 0x0007eb9f flags r-x LOAD off 0x0007eba0 vaddr 0x0007fba0 paddr 0x0007fba0 align 2**12 filesz 0x00001374 memsz 0x00001378 flags rw- DYNAMIC off 0x0007f288 vaddr 0x00080288 paddr 0x00080288 align 2**2 filesz 0x000000e0 memsz 0x000000e0 flags rw- EH_FRAME off 0x00077e00 vaddr 0x00077e00 paddr 0x00077e00 align 2**2 filesz 0x00001234 memsz 0x00001234 flags r-- Dynamic Section: NEEDED libstdc++.so.5 NEEDED libm.so.6 NEEDED libc.so.6 NEEDED libgcc_s.so.1 SONAME libGLU.so.1 INIT 0x13254 FINI 0x71af0 HASH 0xb4 STRTAB 0x7230 SYMTAB 0x2450 STRSZ 0x95dd SYMENT 0x10 PLTGOT 0x8037c PLTRELSZ 0x1578 PLTREL 0x11 JMPREL 0x11cdc REL 0x1127c RELSZ 0xa60 RELENT 0x8 VERNEED 0x111cc VERNEEDNUM 0x4 VERSYM 0x1080e RELCOUNT 0x3a Version References: required from libgcc_s.so.1: 0x0b792650 0x00 08 GCC_3.0 required from libstdc++.so.5: 0x081a2972 0x00 05 GLIBCPP_3.2 0x056bafd2 0x00 04 CXXABI_1.2 required from libc.so.6: 0x09691f73 0x00 07 GLIBC_2.1.3 0x0d696911 0x00 06 GLIBC_2.1 0x0d696910 0x00 03 GLIBC_2.0 required from libm.so.6: 0x0d696910 0x00 02 GLIBC_2.0 coeus@titan ~ $ objdump -p /usr/lib/libglut.so /usr/lib/libglut.so: file format elf32-i386 Program Header: LOAD off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**12 filesz 0x000286f8 memsz 0x000286f8 flags r-x LOAD off 0x00028700 vaddr 0x00029700 paddr 0x00029700 align 2**12 filesz 0x0000d1ec memsz 0x0000d410 flags rw- DYNAMIC off 0x00035388 vaddr 0x00036388 paddr 0x00036388 align 2**2 filesz 0x000000f8 memsz 0x000000f8 flags rw- Dynamic Section: NEEDED libSM.so.6 NEEDED libICE.so.6 NEEDED libXmu.so.6 NEEDED libXext.so.6 NEEDED libXi.so.6 NEEDED libX11.so.6 NEEDED libc.so.6 SONAME libglut.so.3 INIT 0xbcc8 FINI 0x1c760 HASH 0x94 STRTAB 0x2600 SYMTAB 0xb60 STRSZ 0x1a01 SYMENT 0x10 PLTGOT 0x36494 PLTRELSZ 0x610 PLTREL 0x11 JMPREL 0xb6b8 REL 0x4388 RELSZ 0x7330 RELENT 0x8 VERNEED 0x4358 VERNEEDNUM 0x1 VERSYM 0x4002 RELCOUNT 0xda2 Version References: required from libc.so.6: 0x09691f73 0x00 03 GLIBC_2.1.3 0x0d696910 0x00 02 GLIBC_2.0 coeus@titan ~ $ Am Dienstag, 30. Dezember 2003 11:09 schrieb Sven Panne:
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.
*sigh* This kind of problem pops up again and again...
it happens in the package OpenGL, because it is in the package_deps of GLUT.
Correct.
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.
Things are not that easy: Hugs uses the same repository for the hierarchical libraries, and it doesn't have a notion of "package" (yet). So the linker options for every package must be "self contained", otherwise building Hugs would fail. Apart from that, a repetition should not hurt.
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",
While I'm writing this mail, Glynn explains what your problem is (your GLUT is broken). What is the output of "objdump -p" on the dynamic libraries for GLUT/GLU/GL on your system and what platform are you using exactly? On my SuSE 8.2 x86 Linux system, libglut.so.3.7 depends on libGLU.so.1, which in turn depends on libGL.so.1. With this info, dlopen() with the RTLD_GLOBAL can handle the dependencies automatically, regardless of the order of libraries in extra_ld_opts.
For static linking, the order given above is *necessary* for some platforms, e.g. some Solaris versions, IIRC. If library A depends on library B, A must come before B on the linker commandline, full stop. Some platforms/linkers have relaxed this condition, but for maximum portability it must stay this way. Locally you can change your package.conf, of course, but I would recommend testing both ghc with static linking and ghci.
I've never imagined that the configuration handling for GLUT/GLU/GL would be so complicated: There are broken/incomplete/missing headers at various funny locations, broken libraries, differing calling conventions, etc. :-[
Cheers, S.

Marc A. Ziegert wrote:
[...] what is the ghc option to link statically?
Static linking (-static) is the default, I've never tried dynamic linking (-dynamic). A request for the latter one pops up quite regularly, but there are a few reasons why it is not necessarily desirable (=> mailing list archives).
coeus@titan ~ $ cat /usr/lib/libGLU.la [...]
From this you can see that the library dependencies are not quite right on your platform (see the lines starting with "dependency_libs" and "NEEDED"). This is what the final result should look like (modulo some minor differences): panne@jeanluc:~> objdump -p /usr/lib/libglut.so | grep NEEDED NEEDED libSM.so.6 NEEDED libICE.so.6 NEEDED libXmu.so.6 NEEDED libXext.so.6 NEEDED libXi.so.6 NEEDED libX11.so.6 NEEDED libGLU.so.1 NEEDED libc.so.6 panne@jeanluc:~> objdump -p /usr/lib/libGLU.so | grep NEEDED NEEDED libGL.so.1 NEEDED libm.so.6 NEEDED libgcc_s.so.1 NEEDED libc.so.6 panne@jeanluc:~> objdump -p /usr/lib/libGL.so | grep NEEDED NEEDED libGLcore.so.1 NEEDED libm.so.6 NEEDED libXext.so.6 NEEDED libX11.so.6 NEEDED libdl.so.2 I've just had a look at SuSE's source RPM for GLUT/GLU/GL, and they actually do some patching (especially in the Makefile.am files) to get the dependencies right. Perhaps the gentoo people should have a look at this. :-) Cheers, S.

I've just had a look at SuSE's source RPM for GLUT/GLU/GL, and they actually do some patching (especially in the Makefile.am files) to get the dependencies right. Perhaps the gentoo people should have a look at this. :-)
thanks, sven. i'll forward it to gentoo developers. (or first patch it on my own. - gentoo is easy-selfmade-linux.) Happy New Year! - marc Am Dienstag, 30. Dezember 2003 18:51 schrieb Sven Panne:
Marc A. Ziegert wrote:
[...] what is the ghc option to link statically?
Static linking (-static) is the default, I've never tried dynamic linking (-dynamic). A request for the latter one pops up quite regularly, but there are a few reasons why it is not necessarily desirable (=> mailing list archives).
coeus@titan ~ $ cat /usr/lib/libGLU.la [...]
From this you can see that the library dependencies are not quite right on your platform (see the lines starting with "dependency_libs" and "NEEDED"). This is what the final result should look like (modulo some minor differences):
panne@jeanluc:~> objdump -p /usr/lib/libglut.so | grep NEEDED NEEDED libSM.so.6 NEEDED libICE.so.6 NEEDED libXmu.so.6 NEEDED libXext.so.6 NEEDED libXi.so.6 NEEDED libX11.so.6 NEEDED libGLU.so.1 NEEDED libc.so.6 panne@jeanluc:~> objdump -p /usr/lib/libGLU.so | grep NEEDED NEEDED libGL.so.1 NEEDED libm.so.6 NEEDED libgcc_s.so.1 NEEDED libc.so.6 panne@jeanluc:~> objdump -p /usr/lib/libGL.so | grep NEEDED NEEDED libGLcore.so.1 NEEDED libm.so.6 NEEDED libXext.so.6 NEEDED libX11.so.6 NEEDED libdl.so.2
I've just had a look at SuSE's source RPM for GLUT/GLU/GL, and they actually do some patching (especially in the Makefile.am files) to get the dependencies right. Perhaps the gentoo people should have a look at this. :-)
Cheers, S.
_______________________________________________ HOpenGL mailing list HOpenGL@haskell.org http://www.haskell.org/mailman/listinfo/hopengl
participants (3)
-
Glynn Clements
-
Marc A. Ziegert
-
Sven Panne