[ODE] Newbie compilation problems

Olivier Bantiche Olivier.Bantiche at sophia.inria.fr
Thu Aug 7 00:43:02 2003


try this for compilation :

g++ -g -Wall   odetest1.cpp   /usr/lib/libode.a  -o odetest1

Olivier


Jan Ekholm wrote:

>Hi,
>
>I installed 0.039 from a package for "Debian unstable". It contains
>libode.a and the header files and not much else.
>
>Anyway, I can't seem to get even a trivial application compiled using
>either the normal C interface nor the C++ interface that some test apps
>seem to use (but which does not seem to be documented?).
>
>What I try to compile is:
>
>#include <stdlib.h>
>extern "C" {
>#include <ode/ode.h>
>}
>
>int main (int argc, char * argv[]) {
>    // create the ODE world
>    dWorldID world = dWorldCreate();
>    // set standard gravity
>    dWorldSetGravity ( world, 0, 0, -9.81 );
>
>    // here would be dragons
>
>    // we're done
>    dWorldDestroy ( world );
>    dCloseODE();
>
>    // go away
>    exit ( EXIT_SUCCESS );
>}
>
>The error I get is:
>
>g++ -g -Wall   /usr/lib/libode.a  odetest1.cpp   -o odetest1
>/tmp/ccQewNLY.o(.text+0x11): In function `main':
>/home/chakie/prog/c++/ode/odetest1.cpp:11: undefined reference to
>`dWorldCreate'
>/tmp/ccQewNLY.o(.text+0x43):/home/chakie/prog/c++/ode/odetest1.cpp:14:
>undefined reference to `dWorldSetGravity'
>/tmp/ccQewNLY.o(.text+0x51):/home/chakie/prog/c++/ode/odetest1.cpp:19:
>undefined reference to `dWorldDestroy'
>/tmp/ccQewNLY.o(.text+0x59):/home/chakie/prog/c++/ode/odetest1.cpp:20:
>undefined reference to `dCloseODE'
>collect2: ld returned 1 exit status
>make: *** [odetest1] Error 1
>
>I've tried with both gcc and g++, with having the ode.h marked as
>extern "C" and without. The static library /usr/lib/libode.a does seem to
>contain the needed symbols. The only thing I can think of is that libode.a
>has been compiled with some other compiler. So I tested to compile my app
>with g++ versions 3.3, 3.2 and 2.95. No help, so apparently I do something
>really stupid here. I hope it's nothing I have to be too ashamed about.
>
>Another sample using the C++ interface:
>
>
>#include <stdlib.h>
>
>extern "C" {
>#include <ode/ode.h>
>}
>
>static dWorld world;
>
>int main (int argc, char * argv[]) {
>    // set standard gravity
>    world.setGravity ( 0, 0, -9.81 );
>
>    exit ( EXIT_SUCCESS );
>}
>
>
>Give me this:
>
>g++ -g -Wall   /usr/lib/libode.a  odetest1.cpp   -o odetest1
>/tmp/ccouzuZN.o(.gnu.linkonce.t._ZN6dWorldC1Ev+0xb): In function
>`dWorld::dWorld[in-charge]()':
>/usr/include/ode/odecpp.h:42: undefined reference to `dWorldCreate'
>/tmp/ccouzuZN.o(.gnu.linkonce.t._ZN6dWorld10setGravityEddd+0x45): In
>function `dWorld::setGravity(double, double, double)':
>/home/chakie/prog/c++/ode/odetest1.cpp:24: undefined reference to `dWorldSetGravity'
>/tmp/ccouzuZN.o(.gnu.linkonce.t._ZN6dWorldD1Ev+0xf): In function
>`dWorld::~dWorld [in-charge]()':
>/usr/include/ode/odecpp.h:42: undefined reference to `dWorldDestroy'
>collect2: ld returned 1 exit status
>make: *** [odetest1] Error 1
>
>One error that caught my interest was:
>
>    /usr/include/ode/odecpp.h:42: undefined reference to `dWorldCreate'
>
>    33 class dWorld {
>  ...
>    40 public:
>    41   dWorld()
>    42     { _id = dWorldCreate(); }
>
>Is there some problem with missing extern "C" or something similar here,
>as all the includes from ode.h should have defined dWorldCreate() long
>before odecpp.h got included.
>
>The ODE docs are excellent, btw. They are fun reading although I have a
>firm dislike for all things math and physics. :)
>
>Regards,
>    Jan Ekholm
>
>  
>