Linking to Ode

Get answers to all your basic programming questions. No Ogre questions, please!
User avatar
bana
Greenskin
Posts: 132
Joined: Mon Aug 02, 2004 7:40 am
Location: Austin, Texas

Linking to Ode

Post by bana »

I am trying to start with the simplest of the simplest in starting with Ode (I want to work with Ode by itself a bit first before I try to tackle OgreOde) yet I cannot seem to get it to properly compile, here is the code:

Code: Select all

#include <stdio.h>
#include <ode/ode.h>
int main (int argc, char *argv[])
{
   dWorldID bana_world;
   bana_world = dWorldCreate();
   //dWorldSetGravity(bana_world, 0.0f, 0.0f, -9.8f);
   // adjust global ERP and CFM parameters – see documentation

   //dSpaceID bana_space = dSimpleSpaceCreate(bana_space);

   //dJointGroupID bana_joint_group = dJointGroup(0);
   // max_size is deprecated and should be set to 0

   //dBodyID bana_body = dBodyCreate(bana_world);

   //dBodySetPosition(bana_body, 1, 1, 10);
   //dBodySetMass(bana_body, const dMass *mass);


   //dSpaceDestroy(bana_space);
   dWorldDestroy(bana_world);
   //dJointGroupDestroy(bana_joint_group);
   dCloseODE(); // deallocate stuff that doesn’t get    
               // destroyed elsewhere

   return 0;
}
creates this:

Code: Select all

[bana@localhost play]$ g++ -W -L/usr/local/lib/ode/ ode_test.cpp -o ode
/tmp/ccrZXwin.o(.text+0x1d): In function `main':
: undefined reference to `dWorldCreate'
/tmp/ccrZXwin.o(.text+0x2b): In function `main':
: undefined reference to `dWorldDestroy'
/tmp/ccrZXwin.o(.text+0x33): In function `main':
: undefined reference to `dCloseODE'
collect2: ld returned 1 exit status
ode still seems to be linking though as if I comment out all the function calls (only leaving the dWorldID bana_world;) it works fine (but not if I then uncomment the include ode.h).
A proud member of the OpenFrag Coding Team.
http://coolhands.blogspot.com/
User avatar
monster
OGRE Community Helper
OGRE Community Helper
Posts: 1098
Joined: Mon Sep 22, 2003 2:40 am
Location: Melbourne, Australia

Post by monster »

dWorldID is just a typedef in the ODE headers (IIRC) so that'll compile correctly even without linking to the ODE library. The other problems are linking errors, so you're either not linking to ODE, or you're not linking to a compatible library.

I'm no expert on Linux (I assume that's where you're compiling it) but don't you need something like this?

Code: Select all

g++ -W -L/usr/local/lib/ode/ ode_test.cpp -o ode -lode
User avatar
bana
Greenskin
Posts: 132
Joined: Mon Aug 02, 2004 7:40 am
Location: Austin, Texas

Post by bana »

/me slaps forehead

Oops, well that works, I thought that linking to the folder itself would be enough, but apparently I miscalculated (I didn't even need that -L/usr/local... stuff).

Okay thanks Monster, until next time.

(boy am I glad that this is in the Back to Basics Forum and not somewhere else :oops:)
A proud member of the OpenFrag Coding Team.
http://coolhands.blogspot.com/