Bullet on Qt

edma
Posts: 3
Joined: Tue Jan 12, 2010 11:43 am

Bullet on Qt

Post by edma »

Hi all,

I get the bullet2.75.zip file. I used Cmake under Windows 7 to generate Visual Studio project files and finally, using Visual Studio 2008 Express Edition, I compile all Bullet projects (including demos) and the INSTALL project to get include and libs files. These steps were perfectly executed with no problems.

I have a Qt project created and developed under QtCreator that uses bullet. I compile it and executed it with no problems under Linux (ubuntu), but when I try to port it to Windows 7 I get some link problems:

./debug\FLScene.o: In function `FLScene':
C:\Users\Windows7\Development\Qt\flcore/graphics/FLScene.cpp:12: undefined reference to `btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(btDefaultCollisionConstructionInfo const&)'
C:\Users\Windows7\Development\Qt\flcore/graphics/FLScene.cpp:15: undefined reference to `btCollisionDispatcher::btCollisionDispatcher(btCollisionConfiguration*)'
C:\Users\Windows7\Development\Qt\flcore/graphics/FLScene.cpp:18: undefined reference to `btDbvtBroadphase::btDbvtBroadphase(btOverlappingPairCache*)'
C:\Users\Windows7\Development\Qt\flcore/graphics/FLScene.cpp:21: undefined reference to `btSequentialImpulseConstraintSolver::btSequentialImpulseConstraintSolver()'
C:\Users\Windows7\Development\Qt\flcore/graphics/FLScene.cpp:23: undefined reference to `btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDispatcher*, btBroadphaseInterface*, btConstraintSolver*, btCollisionConfiguration*)'
C:\Users\Windows7\Development\Qt\flcore/graphics/FLScene.cpp:53: undefined reference to `btRigidBody::btRigidBody(btRigidBody::btRigidBodyConstructionInfo const&)'
C:\Users\Windows7\Development\Qt\flcore/graphics/FLScene.cpp:12: undefined reference to `btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(btDefaultCollisionConstructionInfo const&)'
C:\Users\Windows7\Development\Qt\flcore/graphics/FLScene.cpp:15: undefined reference to `btCollisionDispatcher::btCollisionDispatcher(btCollisionConfiguration*)'
C:\Users\Windows7\Development\Qt\flcore/graphics/FLScene.cpp:18: undefined reference to `btDbvtBroadphase::btDbvtBroadphase(btOverlappingPairCache*)'
C:\Users\Windows7\Development\Qt\flcore/graphics/FLScene.cpp:21: undefined reference to `btSequentialImpulseConstraintSolver::btSequentialImpulseConstraintSolver()'
C:\Users\Windows7\Development\Qt\flcore/graphics/FLScene.cpp:23: undefined reference to `btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDispatcher*, btBroadphaseInterface*, btConstraintSolver*, btCollisionConfiguration*)'
C:\Users\Windows7\Development\Qt\flcore/graphics/FLScene.cpp:53: undefined reference to `btRigidBody::btRigidBody(btRigidBody::btRigidBodyConstructionInfo const&)'
./debug\FLScene.o:C:\Users\Windows7\Development\Qt\flcore/graphics/FLScene.cpp:174: undefined reference to `btRigidBody::btRigidBody(btRigidBody::btRigidBodyConstructionInfo const&)'
./debug\FLScene.o:c:/bullet/include/BulletCollision/CollisionDispatch/btCollisionObject.h:107: undefined reference to `btAlignedAllocInternal(unsigned int, int)'
./debug\FLScene.o:c:/bullet/include/BulletCollision/CollisionDispatch/btCollisionObject.h:107: undefined reference to `btAlignedFreeInternal(void*)'
./debug\FLScene.o:c:/bullet/include/BulletCollision/CollisionShapes/btConvexShape.h:37: undefined reference to `btAlignedAllocInternal(unsigned int, int)'
./debug\FLScene.o:c:/bullet/include/BulletCollision/CollisionShapes/btConvexShape.h:37: undefined reference to `btAlignedFreeInternal(void*)'
./debug\FLScene.o: In function `btBoxShape':
c:/bullet/include/BulletCollision/CollisionShapes/btBoxShape.h:84: undefined reference to `btPolyhedralConvexShape::btPolyhedralConvexShape()'
c:/bullet/include/BulletCollision/CollisionShapes/btBoxShape.h:84: undefined reference to `vtable for btBoxShape'
./debug\FLScene.o:c:/bullet/include/LinearMath/btAlignedAllocator.h:90: undefined reference to `btAlignedFreeInternal(void*)'
./debug\FLScene.o:c:/bullet/include/LinearMath/btAlignedAllocator.h:86: undefined reference to `btAlignedAllocInternal(unsigned int, int)'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\flcore.dll] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project flcore
When executing build step 'Make'


My .pro file has the following important lines:

QT += sql xml opengl
TARGET = flcore
TEMPLATE = lib
DEFINES += FLCORE_LIBRARY
INCLUDEPATH += model util graphics system c:/bullet/include
LIBS += c:/bullet/lib/BulletDynamics.lib c:/bullet/lib/BulletCollision.lib c:/bullet/lib/LinearMath.lib c:/bullet/lib/BulletSoftBody.lib


Does anyone can help me to resolve this problem please. I already try several solutions but with no success.

Thanks in advance for your reply.
mako90
Posts: 28
Joined: Tue Jan 05, 2010 12:41 pm

Re: Bullet on Qt

Post by mako90 »

Hi,
In gcc (Linux) the order you link the libraries matters. You should link the library used by the others at the end.
See the example:
library libA.a - basic functions
library libB.a - more general fucntions (build on top of libA.a)
library libC.a - the most general functions (built on top of libB.a)

If you link -lA -lB -lC you get the errors from libraries:
B because it cant find functions form A
C because it can't find the functions of B

The solution is: -lC -lB -lA.
edma
Posts: 3
Joined: Tue Jan 12, 2010 11:43 am

Re: Bullet on Qt

Post by edma »

Thanks for your help, but I know that and my problem is not in Linux, but on Windows 7. The error that I have in linking process is on Windows.

Anyone can help me, please?

Thanks in advance for your reply.
mako90
Posts: 28
Joined: Tue Jan 05, 2010 12:41 pm

Re: Bullet on Qt

Post by mako90 »

Hi,
have you tried to use this linking options?

LIBS += c:/bullet/lib/BulletSoftBody.lib c:/bullet/lib/BulletDynamics.lib c:/bullet/lib/BulletCollision.lib c:/bullet
/lib/LinearMath.lib

This is from the manual, try this order:
Required libraries: libbulletdynamics, libbulletcollision, libbulletmath

BR.
edma
Posts: 3
Joined: Tue Jan 12, 2010 11:43 am

Re: Bullet on Qt

Post by edma »

Hi,

I try this:

LIBS += c:/bullet/lib/BulletSoftBody.lib c:/bullet/lib/BulletDynamics.lib c:/bullet/lib/BulletCollision.lib c:/bullet
/lib/LinearMath.lib


with no success. But I don't understand what you say with :

Required libraries: libbulletdynamics, libbulletcollision, libbulletmath

Any idea? I'm getting crazy with this problem...
mako90
Posts: 28
Joined: Tue Jan 05, 2010 12:41 pm

Re: Bullet on Qt

Post by mako90 »

Hi,
does the error log change when the order or libraries changes?
The issue may be that QT does not link the bullet libraries properly.

You may also try to link this way:
LIBS += c:/bullet/lib/BulletSoftBody c:/bullet/lib/BulletDynamics c:/bullet/lib/BulletCollision c:/bullet/lib/LinearMath

Please, send more details.