Hi!
I downloaded Box2D 2.2.1, cd:ed to
sudo make install produced this output:
Then in a project I included Box2D with:
And I added some Box2D lines to see if it would compile:
Then I tried to compile my project with:
Which give me the following error:
However, if I leave the include statement in the file and comment out the 4 other Box2D lines, it compiles fine. What am I missing here?
I downloaded Box2D 2.2.1, cd:ed to
Code:
/home/matachi/Downloads/Box2D_v2.2.1/Build
and then I ran Code:
cmake ..
, Code:
make
and finally Code:
sudo make install
.sudo make install produced this output:
Code:
matachi:Build$ sudo make install
[ 42%] Built target Box2D
[ 43%] Built target HelloWorld
[ 65%] Built target freeglut_static
[ 96%] Built target glui
[100%] Built target Testbed
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/include/Box2D/Box2D.h
-- Installing: /usr/local/include/Box2D/Collision/b2BroadPhase.h
-- Installing: /usr/local/include/Box2D/Collision/b2Collision.h
-- Installing: /usr/local/include/Box2D/Collision/b2Distance.h
-- Installing: /usr/local/include/Box2D/Collision/b2DynamicTree.h
-- Installing: /usr/local/include/Box2D/Collision/b2TimeOfImpact.h
-- Installing: /usr/local/include/Box2D/Collision/Shapes/b2CircleShape.h
-- Installing: /usr/local/include/Box2D/Collision/Shapes/b2EdgeShape.h
-- Installing: /usr/local/include/Box2D/Collision/Shapes/b2ChainShape.h
-- Installing: /usr/local/include/Box2D/Collision/Shapes/b2PolygonShape.h
-- Installing: /usr/local/include/Box2D/Collision/Shapes/b2Shape.h
-- Installing: /usr/local/include/Box2D/Common/b2BlockAllocator.h
-- Installing: /usr/local/include/Box2D/Common/b2Draw.h
-- Installing: /usr/local/include/Box2D/Common/b2GrowableStack.h
-- Installing: /usr/local/include/Box2D/Common/b2Math.h
-- Installing: /usr/local/include/Box2D/Common/b2Settings.h
-- Installing: /usr/local/include/Box2D/Common/b2StackAllocator.h
-- Installing: /usr/local/include/Box2D/Common/b2Timer.h
-- Installing: /usr/local/include/Box2D/Dynamics/b2Body.h
-- Installing: /usr/local/include/Box2D/Dynamics/b2ContactManager.h
-- Installing: /usr/local/include/Box2D/Dynamics/b2Fixture.h
-- Installing: /usr/local/include/Box2D/Dynamics/b2Island.h
-- Installing: /usr/local/include/Box2D/Dynamics/b2TimeStep.h
-- Installing: /usr/local/include/Box2D/Dynamics/b2World.h
-- Installing: /usr/local/include/Box2D/Dynamics/b2WorldCallbacks.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2CircleContact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2Contact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2ContactSolver.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2PolygonContact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2DistanceJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2FrictionJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2GearJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2Joint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2MouseJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2PrismaticJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2PulleyJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2RevoluteJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2RopeJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2WeldJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2WheelJoint.h
-- Installing: /usr/local/include/Box2D/Rope/b2Rope.h
-- Installing: /usr/local/lib/libBox2D.a
-- Installing: /usr/local/lib/Box2D/Box2D-targets.cmake
-- Installing: /usr/local/lib/Box2D/Box2D-targets-noconfig.cmake
-- Installing: /usr/local/lib/Box2D/Box2DConfig.cmake
[ 42%] Built target Box2D
[ 43%] Built target HelloWorld
[ 65%] Built target freeglut_static
[ 96%] Built target glui
[100%] Built target Testbed
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/include/Box2D/Box2D.h
-- Installing: /usr/local/include/Box2D/Collision/b2BroadPhase.h
-- Installing: /usr/local/include/Box2D/Collision/b2Collision.h
-- Installing: /usr/local/include/Box2D/Collision/b2Distance.h
-- Installing: /usr/local/include/Box2D/Collision/b2DynamicTree.h
-- Installing: /usr/local/include/Box2D/Collision/b2TimeOfImpact.h
-- Installing: /usr/local/include/Box2D/Collision/Shapes/b2CircleShape.h
-- Installing: /usr/local/include/Box2D/Collision/Shapes/b2EdgeShape.h
-- Installing: /usr/local/include/Box2D/Collision/Shapes/b2ChainShape.h
-- Installing: /usr/local/include/Box2D/Collision/Shapes/b2PolygonShape.h
-- Installing: /usr/local/include/Box2D/Collision/Shapes/b2Shape.h
-- Installing: /usr/local/include/Box2D/Common/b2BlockAllocator.h
-- Installing: /usr/local/include/Box2D/Common/b2Draw.h
-- Installing: /usr/local/include/Box2D/Common/b2GrowableStack.h
-- Installing: /usr/local/include/Box2D/Common/b2Math.h
-- Installing: /usr/local/include/Box2D/Common/b2Settings.h
-- Installing: /usr/local/include/Box2D/Common/b2StackAllocator.h
-- Installing: /usr/local/include/Box2D/Common/b2Timer.h
-- Installing: /usr/local/include/Box2D/Dynamics/b2Body.h
-- Installing: /usr/local/include/Box2D/Dynamics/b2ContactManager.h
-- Installing: /usr/local/include/Box2D/Dynamics/b2Fixture.h
-- Installing: /usr/local/include/Box2D/Dynamics/b2Island.h
-- Installing: /usr/local/include/Box2D/Dynamics/b2TimeStep.h
-- Installing: /usr/local/include/Box2D/Dynamics/b2World.h
-- Installing: /usr/local/include/Box2D/Dynamics/b2WorldCallbacks.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2CircleContact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2Contact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2ContactSolver.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Contacts/b2PolygonContact.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2DistanceJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2FrictionJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2GearJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2Joint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2MouseJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2PrismaticJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2PulleyJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2RevoluteJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2RopeJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2WeldJoint.h
-- Installing: /usr/local/include/Box2D/Dynamics/Joints/b2WheelJoint.h
-- Installing: /usr/local/include/Box2D/Rope/b2Rope.h
-- Installing: /usr/local/lib/libBox2D.a
-- Installing: /usr/local/lib/Box2D/Box2D-targets.cmake
-- Installing: /usr/local/lib/Box2D/Box2D-targets-noconfig.cmake
-- Installing: /usr/local/lib/Box2D/Box2DConfig.cmake
Then in a project I included Box2D with:
Code:
#include <Box2D/Box2D.h>
And I added some Box2D lines to see if it would compile:
Code:
b2World *m_world;
b2Vec2 gravity;
gravity.Set(0.0f, -10.0f);
m_world = new b2World(gravity);
b2Vec2 gravity;
gravity.Set(0.0f, -10.0f);
m_world = new b2World(gravity);
Then I tried to compile my project with:
Code:
matachi:allegro$ g++ -Wall main.cc components/*.cc systems/*.cc Artemis-Cpp/*.cpp `pkg-config --libs --static allegro-static-5.0` -L /usr/local/lib -I /usr/local/include
Which give me the following error:
Code:
main.cc: In function ‘int main(int, char**)’:
main.cc:50:12: warning: variable ‘m_world’ set but not used [-Wunused-but-set-variable]
/tmp/ccmRqltf.o: In function `main':
main.cc:(.text+0x22e): undefined reference to `b2World::b2World(b2Vec2 const&)'
collect2: error: ld returned 1 exit status
main.cc:50:12: warning: variable ‘m_world’ set but not used [-Wunused-but-set-variable]
/tmp/ccmRqltf.o: In function `main':
main.cc:(.text+0x22e): undefined reference to `b2World::b2World(b2Vec2 const&)'
collect2: error: ld returned 1 exit status
However, if I leave the include statement in the file and comment out the 4 other Box2D lines, it compiles fine. What am I missing here?