cannot statically (cross-)link bullet 2.77 with MinGW

ciphr
Posts: 15
Joined: Mon Mar 28, 2011 9:11 am

cannot statically (cross-)link bullet 2.77 with MinGW

Post by ciphr »

Hello,
I have compiled and cross-compiled Bullet on FreeBSD 8.1. Now I try to link it with my app. Gcc 4.2.1 works fine for static linking, but when I use MinGW 3.4.5, only dynamic linking possible (and was tested to work on windows). If I try to link statically, I get the following output (libs are in /home/ciphr/mingw32/lib):

Code: Select all

/home/ciphr/mingw32/bin/i586-pc-mingw32-g++ -o balls.exe game_visual.o game_bullet.o game_logic.o balls.o -L/home/ciphr/download/crystalspace-src-1.4.0/V1.4/./out/freebsd/optimize/libs -lcrystalspace_windows-1.4 -lcrystalspace_opengl-1.4 -lcrystalspace_directx-1.4 -lcrystalspace-1.4  -L/home/ciphr/mingw32/lib/lib -lzlib -lddraw -ldsound -ldinput -lopengl32 -lm  -L/home/ciphr/mingw32/lib -s -O2 -L/home/ciphr/mingw32/lib -s -O2 -lm -L/usr/local/lib  -L/home/ciphr/bullet-2.77/w32/lib -lBulletDynamics -lBulletCollision -lLinearMath -mwindows -mconsole
game_bullet.o:game_bullet.cpp:(.text+0x2c0): undefined reference to  btDefaultCollisionConfiguration::btDefaultCollisionCon
figuration(btDefaultCollisionConstructionInfo const&)'
game_bullet.o:game_bullet.cpp:(.text+0x33a): undefined reference to `btCollisionDispatcher::btCollisionDispatcher(btCollisi
onConfiguration*)'
game_bullet.o:game_bullet.cpp:(.text+0x3b3): undefined reference to `btDbvtBroadphase::btDbvtBroadphase(btOverlappingPairCa
che*)'
game_bullet.o:game_bullet.cpp:(.text+0x42a): undefined reference to `btSequentialImpulseConstraintSolver::btSequentialImpul
seConstraintSolver()'
game_bullet.o:game_bullet.cpp:(.text+0x4b9): undefined reference to `btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDis
patcher*, btBroadphaseInterface*, btConstraintSolver*, btCollisionConfiguration*)'
game_bullet.o:game_bullet.cpp:(.text+0x74c): undefined reference to `btDefaultCollisionConfiguration::btDefaultCollisionCon
figuration(btDefaultCollisionConstructionInfo const&)'
game_bullet.o:game_bullet.cpp:(.text+0x7c6): undefined reference to `btCollisionDispatcher::btCollisionDispatcher(btCollisi
onConfiguration*)'
game_bullet.o:game_bullet.cpp:(.text+0x83f): undefined reference to `btDbvtBroadphase::btDbvtBroadphase(btOverlappingPairCa
che*)'
game_bullet.o:game_bullet.cpp:(.text+0x8b6): undefined reference to `btSequentialImpulseConstraintSolver::btSequentialImpul
seConstraintSolver()'
game_bullet.o:game_bullet.cpp:(.text+0x945): undefined reference to `btDiscreteDynamicsWorld::btDiscreteDynamicsWorld(btDis
patcher*, btBroadphaseInterface*, btConstraintSolver*, btCollisionConfiguration*)'
game_bullet.o:game_bullet.cpp:(.text+0x10a5): undefined reference to `btRigidBody::btRigidBody(float, btMotionState*, btCol
lisionShape*, btVector3 const&)'
game_bullet.o:game_bullet.cpp:(.text+0x10fd): undefined reference to `btCollisionObject::setActivationState(int)'
game_bullet.o:game_bullet.cpp:(.text+0x1248): undefined reference to `btCapsuleShape::btCapsuleShape(float, float)'
game_bullet.o:game_bullet.cpp:(.text+0x13ec): undefined reference to `btMultiSphereShape::btMultiSphereShape(btVector3 cons
t*, float const*, int)'
game_bullet.o:game_bullet.cpp:(.text+0x18c2): undefined reference to `btStaticPlaneShape::btStaticPlaneShape(btVector3 cons
t&, float)'
game_bullet.o:game_bullet.cpp:(.text+0x1a51): undefined reference to `btBvhTriangleMeshShape::btBvhTriangleMeshShape(btStri
dingMeshInterface*, bool, bool)'
game_bullet.o:game_bullet.cpp:(.text+0x2196): undefined reference to `btTriangleIndexVertexArray::btTriangleIndexVertexArra
y(int, int*, int, int, float*, int)'
game_bullet.o:game_bullet.cpp:(.text$_ZN17btCollisionObjectdlEPv[btCollisionObject::operator delete(void*)]+0xd): undefined
 reference to `btAlignedFreeInternal(void*)'
game_bullet.o:game_bullet.cpp:(.text$_ZN17btCollisionObjectnwEj[btCollisionObject::operator new(
unsigned int)]+0xf): undefined reference to `btAlignedAllocInternal(unsigned int, int)'
game_bullet.o:game_bullet.cpp:(.text$_ZN13btConvexShapedlEPv[btConvexShape::operator delete(void*)]+0xd): undefined reference to `btAlignedFreeInternal(void*)'
game_bullet.o:game_bullet.cpp:(.text$_ZN13btConvexShapenwEj[btConvexShape::operator new(unsigned int)]+0xf): undefined reference to `btAlignedAllocInternal(unsigned int, int)'
game_bullet.o:game_bullet.cpp:(.text$_ZN10btBoxShapeC1ERK9btVector3[btBoxShape::btBoxShape(btVector3 const&)]+0xf): undefined reference to `btPolyhedralConvexShape::btPolyhedralConvexShape()'
game_bullet.o:game_bullet.cpp:(.text$_ZN10btBoxShapeC1ERK9btVector3[btBoxShape::btBoxShape(btVector3 const&)]+0x1b): undefined reference to `vtable for btBoxShape'
game_bullet.o:game_bullet.cpp:(.text$_ZN13btSphereShapedlEPv[btSphereShape::operator delete(void*)]+0xd): undefined reference to `btAlignedFreeInternal(void*)'
game_bullet.o:game_bullet.cpp:(.text$_ZN13btSphereShapeC1Ef[btSphereShape::btSphereShape(float)]+0xd): undefined reference to `btConvexInternalShape::btConvexInternalShape()'
game_bullet.o:game_bullet.cpp:(.text$_ZN13btSphereShapeC1Ef[btSphereShape::btSphereShape(float)]+0x19): undefined reference to `vtable for btSphereShape'
game_bullet.o:game_bullet.cpp:(.text$_ZN13btSphereShapenwEj[btSphereShape::operator new(unsigned int)]+0xf): undefined reference to `btAlignedAllocInternal(unsigned int, int)'
game_bullet.o:game_bullet.cpp:(.text$_ZN22btBvhTriangleMeshShapedlEPv[btBvhTriangleMeshShape::operator delete(void*)]+0xd): undefined reference to `btAlignedFreeInternal(void*)'
game_bullet.o:game_bullet.cpp:(.text$_ZN22btBvhTriangleMeshShapenwEj[btBvhTriangleMeshShape::operator new(unsigned int)]+0xf): undefined reference to `btAlignedAllocInternal(unsigned int, int)'
game_bullet.o:game_bullet.cpp:(.text$_ZN26btTriangleIndexVertexArraydlEPv[btTriangleIndexVertexArray::operator delete(void*)]+0xd): undefined reference to `btAlignedFreeInternal(void*)'
game_bullet.o:game_bullet.cpp:(.text$_ZN26btTriangleIndexVertexArraynwEj[btTriangleIndexVertexArray::operator new(unsigned int)]+0xf): undefined reference to `btAlignedAllocInternal(unsigned int, int)'
game_bullet.o:game_bullet.cpp:(.text$_ZN18btAlignedAllocatorIPN7tehGame8ColliderELj16EE10deallocateEPS2_[btAlignedAllocator<tehGame::Collider*, 16u>::deallocate(tehGame::Collider**)]+0xd): undefined reference to `btAlignedFreeInternal(void*)'
game_bullet.o:game_bullet.cpp:(.text$_ZN18btAlignedAllocatorIPN7tehGame8ColliderELj16EE8allocateEiPPKS2_[btAlignedAllocator<tehGame::Collider*, 16u>::allocate(int, tehGame::Collider* const**)]+0x13): undefined reference to `btAlignedAllocInternal(unsigned int, int)'
game_bullet.o:game_bullet.cpp:(.rdata$_ZTV17btTypedConstraint[vtable for btTypedConstraint]+0x30): undefined reference to `btTypedConstraint::serialize(void*, btSerializer*) const'
game_bullet.o:game_bullet.cpp:(.text$_ZN18btAlignedAllocatorIiLj16EE10deallocateEPi[btAlignedAllocator<int, 16u>::deallocate(int*)]+0xd): undefined reference to `btAlignedFreeInternal(void*)'
game_bullet.o:game_bullet.cpp:(.text$_ZN18btAlignedAllocatorI14btTriangleInfoLj16EE10deallocateEPS0_[btAlignedAllocator<btTriangleInfo, 16u>::deallocate(btTriangleInfo*)]+0xd): undefined reference to `btAlignedFreeInternal(void*)'
game_bullet.o:game_bullet.cpp:(.text$_ZN18btAlignedAllocatorI9btHashIntLj16EE10deallocateEPS0_[btAlignedAllocator<btHashInt, 16u>::deallocate(btHashInt*)]+0xd): undefined reference to `btAlignedFreeInternal(void*)'
balls.o:balls.cpp:(.text$_ZN7tehGame8Collider10SetDampingEff[tehGame::Collider::SetDamping(float, float)]+0x15): undefined reference to `btRigidBody::setDamping(float, float)'
collect2: ld returned 1 exit status
*** Error code 1
Any ideas?
Regards, Igor.

P.S. Don't take Crystal Space stuff into account, since I don't use its built-in Bullet plugin...
Last edited by ciphr on Wed Mar 30, 2011 9:54 am, edited 1 time in total.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: cannot statically (cross-)link bullet 2.77 with MinGW

Post by Erwin Coumans »

Typically the link order is wrong (libraries that depend on other libraries need to go first), or the libraries cannot be found.
(would it report an error in that case?)

I'm not familiar with cross-compiling specific issues.
Thanks,
Erwin
ciphr
Posts: 15
Joined: Mon Mar 28, 2011 9:11 am

Re: cannot statically (cross-)link bullet 2.77 with MinGW

Post by ciphr »

Erwin, I believe that Crystal Space was rebuilt without Bullet support. And gcc (and mingw - with static parts of dynamic libs) accepts this order (but flags for CS are different and platform-dependant). I'll try to reorder stuff though...
P.S. game_* are part of my own code