[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
different library versions
From: |
Rasmus Hahn |
Subject: |
different library versions |
Date: |
Thu, 7 Feb 2002 17:52:57 +0100 |
User-agent: |
Mutt/1.2.5i |
Hello,
I am trying to get a program work which uses two versions
of a library. Short outline:
I am using gcc-3.0.3 to compile a C++ program to build a shared
object of it. This shared object should be loaded via JNI into
a java virtual machine so that some functions can be called from it.
(the facts that the involved components are C++ and JNI are not very
important, but important is that i cannot recompile the java virtual machine
with gcc because I dont have sources). All is done with a linux-gnu-i386
System, so i do not exactly know what circumstances to other
architectures apply.
However the problem is: The standard java VM uses an old version of
libstdc++.so (that of gcc-2) and my shared object uses gcc-3. When
I build my shared object without much efford everything is linked with
dynamic libs and at runtime my shared object loads libstdc++ of gcc-3
as its expected to do. But: Since the java has loaded the old libstdc++
already, symbols with equal names are resolved in the old libstdc++
(this is for example the case for '__dynamic_cast'). Because both
libs are incompatible the program crashes. So I want my shared object
to use the new libstdc++ and java should use the old one.
Without libtool one possibility is to create the shared object by
linking my objects with the (static) archive-version of libstdc++ to
a new object file and then making shared object of it using -Bsymbolic
for local definitions of the new libstdc++.a take precedence.
ld -r a.o b.o c.o /usr/lib/libstdc++.a -o newobj.o
g++ -shared -Wl,-Bsymbolic newobj.o -o newobj.so
The resulting shared object is of course not really shared because the
libstdc++.a is non-PIC but it works at least.
I have not found out how to get a similar effect with libtool, is this
possible at all? What would be the effect of 'ld -r', is it more like
'libtool --mode=link' or more like 'libtool --mode=compile'?
Thanks for your attention despite the clumsy english,
Greetings - Rasmus
--
- different library versions,
Rasmus Hahn <=