gcc 4.3 cannot link: undefined references

Hi,

I can build the latest box2d with gcc 4.3 on debian stable, yet when I try to compile my C++ app with the proper -lbox2d parameter against either Source/Gen/float/ or Source/Gen/fixed it fails saying that the box2d symbols are undefined:

Code:
mac@blacky:~/_code/wasteland$ g++-4.1  -Lbox2d/Source/Gen/float/ -lbox2d `pkg-config --cflags --libs clanCore-0.8 clanDisplay-0.8 clanGL-0.8 clanApp-0.8` -Ibox2d/Include/ frame.cpp actors.cpp game.cpp -o wasteland
/tmp/ccgitMD1.o: In function `Player::Player(CL_DisplayWindow*, b2World*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int)':
actors.cpp:(.text+0x9c7): undefined reference to `b2World::CreateBody(b2BodyDef const*)'
actors.cpp:(.text+0xa03): undefined reference to `b2PolygonDef::SetAsBox(float, float)'
actors.cpp:(.text+0xa31): undefined reference to `b2Body::CreateShape(b2ShapeDef*)'
actors.cpp:(.text+0xa3f): undefined reference to `b2Body::SetMassFromShapes()'
/tmp/ccgitMD1.o: In function `Player::Player(CL_DisplayWindow*, b2World*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int)':
actors.cpp:(.text+0xceb): undefined reference to `b2World::CreateBody(b2BodyDef const*)'
actors.cpp:(.text+0xd27): undefined reference to `b2PolygonDef::SetAsBox(float, float)'
actors.cpp:(.text+0xd55): undefined reference to `b2Body::CreateShape(b2ShapeDef*)'
actors.cpp:(.text+0xd63): undefined reference to `b2Body::SetMassFromShapes()'
/tmp/cc4sYN59.o: In function `Game::main(int, char**)':
game.cpp:(.text+0x1c2): undefined reference to `b2World::b2World(b2AABB const&, b2Vec2 const&, bool)'
game.cpp:(.text+0x46d): undefined reference to `b2World::Step(float, int)'
collect2: ld returned 1 exit status


The same problem exists with g++-4.1 on the same debian system. Any help with this problem highly appreciated!

Cheers
Mac
Interestingly, I can compile using each and every single object file rather than the library .a file... this now works:

Code:
c++ box2d/Source/Gen/float/Collision/Shapes/b2Shape.o \
box2d/Source/Gen/float/Collision/Shapes/b2CircleShape.o \
box2d/Source/Gen/float/Collision/Shapes/b2PolygonShape.o \
box2d/Source/Gen/float/Collision/b2Collision.o \
box2d/Source/Gen/float/Collision/b2Distance.o \
box2d/Source/Gen/float/Collision/b2TimeOfImpact.o \
box2d/Source/Gen/float/Collision/b2PairManager.o \
box2d/Source/Gen/float/Collision/b2CollidePoly.o \
box2d/Source/Gen/float/Collision/b2CollideCircle.o \
box2d/Source/Gen/float/Collision/b2BroadPhase.o \
box2d/Source/Gen/float/Common/b2StackAllocator.o \
box2d/Source/Gen/float/Common/b2Math.o \
box2d/Source/Gen/float/Common/b2BlockAllocator.o \
box2d/Source/Gen/float/Common/b2Settings.o \
box2d/Source/Gen/float/Dynamics/Joints/b2MouseJoint.o \
box2d/Source/Gen/float/Dynamics/Joints/b2PulleyJoint.o \
box2d/Source/Gen/float/Dynamics/Joints/b2Joint.o \
box2d/Source/Gen/float/Dynamics/Joints/b2RevoluteJoint.o \
box2d/Source/Gen/float/Dynamics/Joints/b2PrismaticJoint.o \
box2d/Source/Gen/float/Dynamics/Joints/b2DistanceJoint.o \
box2d/Source/Gen/float/Dynamics/Joints/b2GearJoint.o \
box2d/Source/Gen/float/Dynamics/Contacts/b2Contact.o \
box2d/Source/Gen/float/Dynamics/Contacts/b2PolyContact.o \
box2d/Source/Gen/float/Dynamics/Contacts/b2CircleContact.o \
box2d/Source/Gen/float/Dynamics/Contacts/b2PolyAndCircleContact.o \
box2d/Source/Gen/float/Dynamics/Contacts/b2ContactSolver.o \
box2d/Source/Gen/float/Dynamics/b2Body.o \
box2d/Source/Gen/float/Dynamics/b2Island.o \
box2d/Source/Gen/float/Dynamics/b2World.o \
box2d/Source/Gen/float/Dynamics/b2ContactManager.o \
box2d/Source/Gen/float/Dynamics/b2WorldCallbacks.o \
`pkg-config --cflags --libs   clanCore-0.8 clanDisplay-0.8 clanGL-0.8 clanApp-0.8` -Ibox2d/Include/ -Lbox2d/Source/Gen/float -lbox2d frame.cpp    actors.cpp game.cpp -o wasteland


Looks like there's something wrong with the libbox2d.a file... yet it is of the proper type and doesn't look like it's corrupted (I tried building it with another version of gcc as well)

Code:
mac@blacky:~/_code/wasteland$ file /usr/lib/libpng12.a
/usr/lib/libpng12.a: current ar archive
mac@blacky:~/_code/wasteland$ file box2d/Source/Gen/float/libbox2d.a
box2d/Source/Gen/float/libbox2d.a: current ar archive


Very odd... maybe someone can help me figure out what's wrong with the library?

Cheers
Mac
Yep, the problem is that the macro TARGET_FLOAT32_IS_FIXED is (or is not) defined when building the library, and the opposite is true when building whatever project you are building. That makes the function signatures for the specific methods which uses the float32 type differ between the static library and the compiled project object files.

Headers are important : P. Took me some time to figure this out the first time. I've written this in the README for the groundzero branch.

Original thread: https://box2d.org/forum/viewtopic.php?t=2786