Static linking of bullet in my app (linux, gcc)

User avatar
godlike
Posts: 20
Joined: Fri Feb 19, 2010 7:09 pm

Static linking of bullet in my app (linux, gcc)

Post by godlike »

I've build bullet statically and successfully created a few .a files. Now I want to use this static libs in my app. My link command line is:

Code: Select all

-rdynamic -Bdynamic -lGL -lGLU -lSDL_image -ljpeg -lGLEW -Bstatic `sdl-config --static-libs` -L../../../bullet_svn/src/BulletDynamics -lBulletDynamics -L../../../bullet_svn/src/BulletCollision -lBulletCollision -L../../../bullet_svn/src/LinearMath -lLinearMath -L../../../bullet_svn/src/BulletSoftBody -lBulletSoftBody
The problem is that I get a linkage error:

Code: Select all

main.o:(.rodata._ZTV17btTypedConstraint[vtable for btTypedConstraint]+0x60): undefined reference to `btTypedConstraint::serialize(void*, btSerializer*) const'
When I use the dynamic libraries of bullet the linking caries out successfully. Any ideas?

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

Re: Static linking of bullet in my app (linux, gcc)

Post by Erwin Coumans »

Strange, I've not seen this before.

The Bullet demos are using static linking by default. Have you tried building the demos using cmake, and does that work for you?

Make sure the link order is: BulletSoftBody, BulletDynamics, BulletCollision and LinearMath.

Thanks,
Erwin
User avatar
godlike
Posts: 20
Joined: Fri Feb 19, 2010 7:09 pm

Re: Static linking of bullet in my app (linux, gcc)

Post by godlike »

After a long search this is the magic link command:

Code: Select all

gcc <list of .o> -rdynamic -L../../../bullet_svn/src/BulletSoftBody -L../../../bullet_svn/src/BulletDynamics -L../../../bullet_svn/src/BulletCollision -L../../../bullet_svn/src/LinearMath -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lSDL_image -lGLU -Wl,-Bdynamic -lSDL -lpthread -lGL -ljpeg -lpng -ltiff
You have to put "-Wl,-Bstatic" before "-Wl,-Bdynamic" and resolve any dependency that bullet needs