Trouble Integrating Bullet with Mac OS X App

Mikamura
Posts: 2
Joined: Sun Dec 02, 2007 2:31 am

Trouble Integrating Bullet with Mac OS X App

Post by Mikamura »

Hello all,

I seem to be having trouble integrating bullet with an OpenGL application I have. I was looking through the user manual (on page 5) and on step 4 it says to include the bullet src folder and three libraries. I tried to link to those libraries and compile my application with a Makefile but it is giving me this:

------

make

g++ -DOGL_CASTS_USE_DOTS -DMAC_OS -g -o proj4 proj4.o Building.o Ground.o Vector.o Triangle.o BMPLoader.o Divide.o Pillar.o Roof.o MagicMaker.o Picture.o TexHandler.o Door.o TGAImageReader.o -L/usr/X11R6/lib -LbulletSrc/BulletDynamics -LbulletSrc/BulletCollision -LbulletSrc/LinearMath -framework OpenGL -framework GLUT -framework Foundation

/usr/bin/ld: Undefined symbols:
btAlignedFreeInternal(void*)
btAlignedAllocInternal(unsigned long, int)
btPolyhedralConvexShape::btPolyhedralConvexShape()
btCollisionShape::getBoundingSphere(btVector3&, float&) const
btCollisionShape::getAngularMotionDisc() const
typeinfo for btCollisionShape
vtable for btBoxShape
vtable for btCollisionShape
vtable for btConvexInternalShape
vtable for btPolyhedralConvexShape
collect2: ld returned 1 exit status
make: *** [proj4] Error 1

------

The error only appears when I make this call in my code (taken from the DemoApplication):
btCollisionShape* m_shootBoxShape = new btBoxShape(btVector3(0.5f,0.5f,0.5f));

I've tried running the demos and they run just fine, which leads me to believe I'm probably not including/linking to something I should be. I took the src directory from the bullet download and renamed it "bulletSrc" and put it in my application directory. I also linked to the BulletDynamics, BulletCollision, and LinearMath directories within the bullet src directory, which I assumed would cover the libraries I needed to include (but that may not be the case?). Here's a copy of my Makefile for reference:

Code: Select all

# name of executable file
PROG = proj4

# -DMAC_OS is a compiler variable we use to inform our code we're compiling with mac  
CPP = g++ -DOGL_CASTS_USE_DOTS -DMAC_OS

# Include the bullet src folder 
C_FLAGS = -g -c -IbulletSrc -I/usr/X11R6/include 

# Link to the bullet and OpenGL libraries
LIB = -L/usr/X11R6/lib -LbulletSrc/BulletDynamics -LbulletSrc/BulletCollision -LbulletSrc/LinearMath

GRAPHICS_LIBRARIES = -framework OpenGL -framework GLUT -framework Foundation

# Our object files
OBJS = $(PROG).o Building.o Ground.o Vector.o Triangle.o BMPLoader.o Divide.o Pillar.o Roof.o MagicMaker.o Picture.o TexHandler.o Door.o TGAImageReader.o

$(PROG): $(OBJS)
	$(CPP) -g -o $(PROG) $(OBJS) $(LIB) $(GRAPHICS_LIBRARIES)

$(PROG).o: $(PROG).cpp
	$(CPP) $(C_FLAGS) $(PROG).cpp

Building.o: Building.cpp Building.h
	$(CPP) $(C_FLAGS) Building.cpp 
Ground.o: Ground.cpp Ground.h
	$(CPP) $(C_FLAGS) Ground.cpp
Vector.o: Vector.cpp Vector.h
	$(CPP) $(C_FLAGS) Vector.cpp
Triangle.o: Triangle.cpp Triangle.h
	$(CPP) $(C_FLAGS) Triangle.cpp
BMPLoader.o: BMPLoader.cpp BMPLoader.h
	$(CPP) $(C_FLAGS) BMPLoader.cpp
Divide.o: Divide.cpp Divide.h
	$(CPP) $(C_FLAGS) Divide.cpp
Pillar.o: Pillar.cpp Pillar.h
	$(CPP) $(C_FLAGS) Pillar.cpp
Roof.o: Roof.cpp Roof.h
	$(CPP) $(C_FLAGS) Roof.cpp
MagicMaker.o: MagicMaker.cpp MagicMaker.h
	$(CPP) $(C_FLAGS) MagicMaker.cpp
Picture.o: Picture.cpp Picture.h
	$(CPP) $(C_FLAGS) Picture.cpp
TexHandler.o: TexHandler.cpp TexHandler.h
	$(CPP) $(C_FLAGS) TexHandler.cpp
Door.o: Door.cpp Door.h
	$(CPP) $(C_FLAGS) Door.cpp
TGAImageReader.o: TGAImageReader.cpp TGAImageReader.h
	$(CPP) $(C_FLAGS) TGAImageReader.cpp
Any ideas? Please let me know if I need to clarify something.

Thanks,

Mika
hiker
Posts: 83
Joined: Tue Oct 24, 2006 11:52 pm
Location: Australia

Re: Trouble Integrating Bullet with Mac OS X App

Post by hiker »

Hi,

you are not linking in the bullet libraries:
g++ -DOGL_CASTS_USE_DOTS -DMAC_OS -g -o proj4 proj4.o Building.o Ground.o Vector.o Triangle.o BMPLoader.o Divide.o Pillar.o Roof.o MagicMaker.o Picture.o TexHandler.o Door.o TGAImageReader.o -L/usr/X11R6/lib -LbulletSrc/BulletDynamics -LbulletSrc/BulletCollision -LbulletSrc/LinearMath -framework OpenGL -framework GLUT -framework Foundation
-L specifies the path to the libraries, it does not link the libraries. You have to use -l, e.g. here is what I am using:

Code: Select all

... -L bullet/src -lbulletdynamics -lbulletcollision -lbulletmath
This of course assumes that the three bullet libraries are in bullet/src :) From the ld man page:
-larchive ...
Add archive file archive to the list of files to link ... ld will search its path-list for occurrences of "libarchive.a"
Cheers,
Joerg
Mikamura
Posts: 2
Joined: Sun Dec 02, 2007 2:31 am

Re: Trouble Integrating Bullet with Mac OS X App

Post by Mikamura »

Yep, that did the trick. I changed my LIB line to

Code: Select all

LIB = -LbulletSrc -lLibBulletDynamics -lLibBulletCollision -lLibLinearMath
Thanks Joerg!

Mika