Linker error: new user, what am I doing wrong?

Nick
Posts: 3
Joined: Tue Oct 12, 2010 1:52 pm

Linker error: new user, what am I doing wrong?

Post by Nick »

Hi all,

I apologise in advance for the undoubtedly newbie error. I'm just getting started trying to use Bullet in an XCode CPP project. I've built and installed Bullet as a Mac OS X framework as discussed at http://bulletphysics.org/mediawiki-1.5. ... ork_Recipe.

I'm now trying to get XCode to build the following noddy file:

Code: Select all

#include <iostream>

#include <BulletDynamics/btBulletDynamicsCommon.h>

int main (int argc, char * const argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    return 0;
}
and I'm faced with the following from the linker:

Code: Select all

Undefined symbols:
  "btTypedConstraint::serialize(void*, btSerializer*) const", referenced from:
      vtable for btTypedConstraintin main.o
  "btAlignedFreeInternal(void*)", referenced from:
      btAlignedAllocator<btHashInt, 16u>::deallocate(btHashInt*) in main.o
      btAlignedAllocator<btTriangleInfo, 16u>::deallocate(btTriangleInfo*)in main.o
      btAlignedAllocator<int, 16u>::deallocate(int*)  in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Can anyone help me work out what I'm doing wrong? It looks like my #include directive is working, but there's some library path issue after that?

-N
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Linker error: new user, what am I doing wrong?

Post by Erwin Coumans »

Have you tried static linking the libraries, instead of frameworks/dynamic linkage? That should work.

Thanks,
Erwin
arsnic
Posts: 3
Joined: Sat Oct 23, 2010 4:31 pm

Re: Linker error: new user, what am I doing wrong?

Post by arsnic »

Sorry I have the same problem. How do we not link via the framework then? I have tried also adding the BulletDynamic framework in the project properties. If someone gets this working it might be helpful to write a small tut.
Nick
Posts: 3
Joined: Tue Oct 12, 2010 1:52 pm

Re: Linker error: new user, what am I doing wrong?

Post by Nick »

Having now got this working, I think there isn't a problem at all, it was just a case of me not understanding XCode.

You need to tell XCode which Framework libraries you want to link against by going to

Project -> Edit Active Target "..."

and then under "Linked libraries" you need to add BulletCollision.framework, BulletDynamics.framework and LinearMath.framework.

Hope this helps,
Nick
arsnic
Posts: 3
Joined: Sat Oct 23, 2010 4:31 pm

Re: Linker error: new user, what am I doing wrong?

Post by arsnic »

Thanks Nick,

I actually am using Eclipse instead of Xcode. I had added Bullet as a framework and it still didn't work, maybe I'll link it as a library instead. Anybody know specifically what the difference between a Framework and a library might be?

Thanks again Nick.
arsnic
Posts: 3
Joined: Sat Oct 23, 2010 4:31 pm

Re: Linker error: new user, what am I doing wrong?

Post by arsnic »

Ok I have found the solution to the Eclipse use as well.
When using Eclipse, on Mac, create your project and copy in what code you will from the examples, etc.

To load the Bullet Libraries:

- right-click on the project
- click Properties
- expand C/C++ Build to the left
- click Settings
- ensure you are on the "Tool Settings" tab
- click "Libraries" under MacOS X C++ Linker
- click add for the Library search path (-L)
- type "/Library/Frameworks", without quotes click ok
- click add for Libraries (-l) and add the libraries you need, mine were BulletCollision, BulletDynamics, and LinearMath, basically the framework without .framework
Optional (if you need OpenGL or GLUT):
- click "Miscellaneous" under MacOS X C++ Linker
- in the Linker flags box type, "-framework GLUT -framework OpenGL"


There for anyone else with issues, that should solve them.