[ODE] Impossible static linking of libode

Andreas Beckermann b_mann at gmx.de
Wed Oct 24 12:39:10 MST 2007

Well, when you switch from dynamic to static linking, you usually have to take 
more care of library dependencies.
For example with dynamic linking -lOgreMain would work just fine, if you 
wanted to link against OGRE.
However with static linking you also need to add e.g. libfreeimage, libGL, 
libX11, ... (unless some other library that you link dynamically against 
pulls them in).

And last but not least the order of libraries is very important, 
e.g. -lode -logreode may work with dynamic libraries (because ogreode pulls 
in ode itself), but it is doomed to fail for static linking, because ogreode 
requires ode, but those symbols already have been resolved when ogreode is 
(Forgive me, if that was not technically correct, I am not a linking expert or 
so. But the end result surely is correct)

That said, I have actually no idea what you are doing - if you 
add "-L/usr/local/lib/libode.a" the effect should (imho) be either an error 
or that this parameter is ignored, becase libode.a is not a directory (and -L 
expects one). Also I you said you changed the -lode, but you use OgreOde... 
did you change that one, too? Or did you mean that one?

I imagine that your g++ liner line should look something like this
  g++ <objects> -o target -lOgreOde_Core -Wl,-Bstatic -lode -Wl,-Bdynamic
-> this should like against OgreOde_Core dynamically, but statically against 
ODE (assuming OgreOde _links_ against ODE, but does not provide a copy of ODE 
(note the -Wl,-Bdynamic at the end of the line .. this is somwhat important!)

I would expect that that should work, however when it comes to static linking, 
a bit of experimenting is usually required (well, for me anyway ;-))


On Wednesday 24 October 2007, Ivan M wrote:
> Oh yes! I remember the reason. One day already I forced the link
> command and change "-lode" for "-L/usr/local/lib/libode.a". If I
> forced, the list of undefined reference floods my shell. For example:
> /usr/local/lib/libOgreOde_Core.a(OgreOdeMass.o): In function `dMass':
> /usr/local/include/ode/mass.h:92: referencia a `dMassSetZero' sin definir
> I don't say one think that i see that its very important: I don't use
> ode directly, I use  the wrapper OgreOde!!! Possible it is
> incompatible the static version of OgreOde libs with the static
> version of Ode lib???
> On 10/24/07, Andreas Beckermann <b_mann at gmx.de> wrote:
> > On Tuesday 23 October 2007, Ivan M wrote:
> > > Hi,
> > > I have been trying to compile/linking statically the libode several
> > > days and I don't guess it.
> > > I compile/installed ode in my Ubuntu with the --enable-static option,
> > > and I have 2 libode - libode.a and libode.so. It seems that the "gcc
> > > doesn't see" the libode.a and then link with libode.so dynamically.
> > >
> > > It is possible to link libode statically with my application? And how?
> > >
> > > Thanks,
> > > Ivan.
> >
> > Try to add -Wl,-Bstatic to you gcc linker line before you specify the ODE
> > library (and -Wl,-Bdynamic afterwards to "undo" this option)
> >
> > CU
> > Andi
> > _______________________________________________
> > ODE mailing list
> > ODE at ode.org
> > http://ode.org/mailman/listinfo/ode
> _______________________________________________
> ODE mailing list
> ODE at ode.org
> http://ode.org/mailman/listinfo/ode

More information about the ODE mailing list