Link error [SOLVED]

Jonan
Posts: 10
Joined: Mon Oct 27, 2008 9:31 am

Link error [SOLVED]

Post by Jonan »

I'm using Ubuntu 8.04 and Bullet 2.72 and I have no problems when compiling my code, but when it's time to link I get errors like this one:

Code: Select all

undefined reference to `btDefaultCollisionConfiguration::~btDefaultCollisionConfiguration()'
I'm passing this parameters to gcc:

Code: Select all

-I/usr/local/include/bullet -L/usr/local/lib -lbulletdynamics -lbulletcollision -lbulletmath
Am I doing something wrong?

Thanks in advance.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Link error

Post by Erwin Coumans »

What build system are you using? Cmake, Jam, autotools+make?
I get errors like this one
What other errors, except for btDefaultCollisionConfiguration?
Thanks,
Erwin
Jonan
Posts: 10
Joined: Mon Oct 27, 2008 9:31 am

Re: Link error

Post by Jonan »

I'm using a custom Makefile. The command that creates the final executable is this one:

Code: Select all

g++ -Wall -g -DOGRE_GUI_GLX -DOGRE_CONFIG_LITTLE_ENDIAN -I/usr/local/include/bullet -I/usr/local/include/OIS -I/usr/local/include -I/usr/include/CEGUI -I/usr/include/OGRE    -L/usr/local/lib -lbulletdynamics -lbulletcollision -lbulletmath -lCEGUIOgreRenderer -lCEGUIBase -lOgreMain -lOIS -o executable_name all_object_files
Jonan
Posts: 10
Joined: Mon Oct 27, 2008 9:31 am

Re: Link error

Post by Jonan »

I've tried compiling the Hello World example instead of my one application and this is the result:

source code:

Code: Select all

#include <btBulletDynamicsCommon.h>
#include <iostream>

int main () {
    std::cout << "Hello World!" << std::endl;

    // Build the broadphase
    int maxProxies = 1024;
    btVector3 worldAabbMin(-10000,-10000,-10000);
    btVector3 worldAabbMax(10000,10000,10000);
    btAxisSweep3* broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);

    // Set up the collision configuration and dispatcher
    btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
    btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);

    // The actual physics solver
    btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;

    // The world.
    btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,broadphase,solver,collisionConfiguration);


    // Do_everything_else_here


    // Clean up behind ourselves like good little programmers
    delete dynamicsWorld;
    delete solver;
    delete dispatcher;
    delete collisionConfiguration;
    delete broadphase;

    return 0;
}
compilation:

Code: Select all

$ g++ -I/usr/local/include/bullet -L/home/jonan/Escritorio/bullet-2.72/out/linuxx86/optimize/libs -lbulletdynamics -lbulletcollision -lbulletmath main.cpp -o bullet
/tmp/ccxHcss7.o: In function `main':
main.cpp:(.text+0x268): undefined reference to `btAxisSweep3::btAxisSweep3(btVector3 const&, btVector3 const&, unsigned short, btOverlappingPairCache*)'
main.cpp:(.text+0x2a3): undefined reference to `btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(btDefaultCollisionConstructionInfo const&)'
main.cpp:(.text+0x303): undefined reference to `btCollisionDispatcher::btCollisionDispatcher(btCollisionConfiguration*)'
main.cpp:(.text+0x356): undefined reference to `btSequentialImpulseConstraintSolver::btSequentialImpulseConstraintSolver()'
main.cpp:(.text+0x3c2): undefined reference to `btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDispatcher*, btBroadphaseInterface*, btConstraintSolver*, btCollisionConfiguration*)'
Jonan
Posts: 10
Joined: Mon Oct 27, 2008 9:31 am

Re: Link error

Post by Jonan »

I found the answer in this post. I have to put objects files before libs when linking.