[squeak-dev] FFI/linux dynamic library load order?

Eliot Miranda eliot.miranda at gmail.com
Thu Jan 5 18:07:52 UTC 2012

On Thu, Jan 5, 2012 at 6:27 AM, Hans-Martin Mosner <hmm at heeg.de> wrote:

> Hello,
> after some wasted hours tracking down why my OpenGL code does not work at
> all, I found that Squeak probably loaded the
> wrong GL.so library - instead of /usr/lib/nvidia-current/libGL.so it
> loaded /usr/lib/i386-linux-gnu/mesa/libGL.so.
> C programs compiled with -lGL use the correct library, of course. Does
> anyone have an idea what causes this confusing
> behavior, and what can be done to fix it? BTW, my VM is the Cog 3.9-7 VM -
> when I try the 4.0-2522 Cog VM, the module
> "X11" can't be found, possibly because naming conventions changed
> somewhere?

All I can say is that one must set LD_LIBRARY_PATH appropriately so that
the VM will pick things up from the right places.  You can use ldd to find
out what the VM is linked against.  e.g.

bash-2.05b$ ldd cogvm/4.0-2518/vm-display-X11
        libGL.so.1 => /usr/lib/libGL.so.1 (0x4002e000)
        libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40093000)
        libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x400a1000)
        libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x400a9000)
        libdl.so.2 => /lib/libdl.so.2 (0x400c0000)
        libpthread.so.0 => /lib/tls/libpthread.so.0 (0x400c3000)
        libm.so.6 => /lib/tls/libm.so.6 (0x400d4000)
        libnsl.so.1 => /lib/libnsl.so.1 (0x400f6000)
        libuuid.so.1 => /lib/libuuid.so.1 (0x4010b000)
        libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x4010e000)
        libc.so.6 => /lib/tls/libc.so.6 (0x401ed000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

Then from the libGL info one can craft a suitable LD_LIBRARY_PATH, e.g. one
with the directory containing the libGL.so.N the VM is linked against
first.  So in your example above

LD_LIBRARY_PATH=/usr/lib/nvidia-current:$LD_LIBRARY_PATH cogvm/squeak


> Cheers,
> Hans-Martin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20120105/f5b5d4c5/attachment.htm

More information about the Squeak-dev mailing list