[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to hook into shared libraries (by chaining)

From: Christian Parpart
Subject: how to hook into shared libraries (by chaining)
Date: Tue, 13 Feb 2007 11:59:35 +0100
User-agent: KMail/1.9.6

Hi all,

somewhat unusual, I do understand, but I most obviousely need this.

I want to override some functions located in and, in order 
to capture movies from (any) OpenGL application.

There are now several ways to achieve this, but none of them seems to be 
userfriendly *and* ideal (system/platform independant).

One way is, to enforce the user to LD_PRELOAD=foo everytime he expects to push 
the `capture` button. This works quite well, but you'd have to hack the 
ut2004 shell script, cedega, and only #devil knows what else.

So, another approach I thought of, was, to reimplement the client GL library. 
But this is not just time consuming, as you've to wrap really really all 
little nasty functions like glVertex{234}{sifd}[v] and friends - and is even 
too much performance overhead, as really every little functions is wrapped 
instead only those you need.

So I found yukon which does seem to have found a way by having a script that 
LD_LIBRARY_PATH's the app you're about to capture a movie from its GL 
However, yukon's build system[1] is far from using autotools nor do I believe, 
that post-patching binaries is the right way to go.

I believe chaining the library you're interested in is great.

        1) clientApp.bin depends on
        2) is a symlink to $PREFIX/
        3) $PREFIX/ depends on real

Unfortunately, I couldn't find anything in's man-page about such a 
feature, so I thought about replacing step (3) by the following:

        3) $PREFIX/ so depends on $PREFIX/
        4) $PREFIX/ is a symlink to /usr/lib/

Where $PREFIX in /etc/ is listed above /usr/lib{,32,64} to let our 
(chained) being loaded first.

Unfortunately, automake/libtool doesn't have any syntax to express such a 
feature, and I'd just end up (again) in hooking into's 
post install rule:

# -------------------------------------------------------------------

libGLcaptury_la_SOURCES = libGLcaptury.cpp
libGLcaptury_la_LDFLAGS = -version-info @CAPTURY_VERSION_INFO@
libGLcaptury_la_LIBADD = \
    $(top_builddir)/src/captury/ \

libGLsystem_la_SOURCES = #
libGLsystem_la_LDFLAGS = -version-info 1:0:0

SYSGL_libdir = /usr/lib64 # determined by configure

    rm $(DESTDIR)/$(SYSGL_libdir)/libGLsystem.{so,a,la}
    ln -s $(SYSGL_libdir)/ $(DESTDIR)$(libdir)/
# -------------------------------------------------------------------

This is a quote form my current I did a little workaround here to 
get a `virtual` I can link against. But I unfortunately (as in 
fact it isn't really `virtual`) have to post-delete the installed files in 
install-exec-local and install the symlink to the system's real 

I'd like to get some feedback from you what/how you do think about, and/or how 
you'd have implemented such a thing.

So... thanks in advance,
Christian Parpart.

[1] svn://

Attachment: pgp_oErTloFVn.pgp
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]