Box2D for GNU/Linux with Makefile

I couldn't find this anywhere else, so I made it myself: Box2d easily compilable on GNU/Linux systems.

Download it here.

The only thing missing now is the use of autotools, but I think simply having a Makefile might be quite helpful for most people.
Would be nice if this could be integrated in the official download package. 🙂

How to use:
To compile:
Code:
tar -xzvf Box2D_v1.4.0.tar.gz
cd Box2D_v1.4.0/Box2D
make


To run the test programs:
Code:
cd ./Examples/HelloWorld
./run

Code:
cd ./Examples/TestBed
./run

(The run files are just scripts doing "export LD_LIBRARY_PATH=../../Library:$LD_LIBRARY_PATH" and running the programs.)

Modified source files:
Contrib/glui/GL/glui.h
Contrib/glui/readme.txt
Examples/TestBed/Framework/Main.cpp
Examples/TestBed/Framework/Render.cpp
Examples/TestBed/Framework/Test.cpp
Examples/TestBed/Tests/PolyCollision.h
Source/Common/b2Math.h

Added Makefiles:
./Contrib/glui/Makefile
./Examples/HelloWorld/Makefile
./Examples/TestBed/Framework/Makefile
./Examples/TestBed/Tests/Makefile
./Examples/TestBed/Makefile
./Source/Collision/Makefile
./Source/Common/Makefile
./Source/Dynamics/Contacts/Makefile
./Source/Dynamics/Joints/Makefile
./Source/Dynamics/Makefile
./Source/Makefile
./Makefile

Binaries created:
./Contrib/glui/libglui.so
./Library/libbox2d.so
./Library/libglui.so
./Source/libbox2d.so
./Examples/TestBed/Main
./Examples/HelloWorld
./Examples/HelloWorld/HelloWorld
Modifications I had to make:
Code:
$diff -r Box2D_v1.4.0 fresh2/Box2D_v1.4.0

diff -r Box2D_v1.4.0/Box2D/Contrib/glui/GL/glui.h fresh2/Box2D_v1.4.0/Box2D/Contrib/glui/GL/glui.h
53,55c53,54
<       //necessary change to compile under GNU/Linux
<       //#include "../../freeglut/gl/glut.h"
<       #include <GL/glut.h>
---
>       #include "../../freeglut/gl/glut.h"
>   //#include <GL/glut.h>
Only in Box2D_v1.4.0/Box2D/Contrib/glui: Makefile
Only in Box2D_v1.4.0/Box2D/Examples/HelloWorld: Makefile
Only in Box2D_v1.4.0/Box2D/Examples/HelloWorld: run
diff -r Box2D_v1.4.0/Box2D/Examples/TestBed/Framework/Main.cpp fresh2/Box2D_v1.4.0/Box2D/Examples/TestBed/Framework/Main.cpp
21,23c21
< //necessary change to compile under GNU/Linux
< // #include "glui/gl/glui.h"
< #include "glui/GL/glui.h"
---
> #include "glui/gl/glui.h"
Only in Box2D_v1.4.0/Box2D/Examples/TestBed/Framework: Makefile
diff -r Box2D_v1.4.0/Box2D/Examples/TestBed/Framework/Render.cpp fresh2/Box2D_v1.4.0/Box2D/Examples/TestBed/Framework/Render.cpp
21,23c21
< //necessary change to compile under GNU/Linux
< //#include "freeglut/gl/glut.h"
< #include <GL/glut.h>
---
> #include "freeglut/gl/glut.h"
26,27d23
< //necessary change to compile under GNU/Linux
< #include <stdarg.h>
diff -r Box2D_v1.4.0/Box2D/Examples/TestBed/Framework/Test.cpp fresh2/Box2D_v1.4.0/Box2D/Examples/TestBed/Framework/Test.cpp
22,24c22
< //necessary change to compile under GNU/Linux
< //#include "freeglut/gl/glut.h"
< #include <GL/glut.h>
---
> #include "freeglut/gl/glut.h"
Only in Box2D_v1.4.0/Box2D/Examples/TestBed: Makefile
Only in Box2D_v1.4.0/Box2D/Examples/TestBed: run
Only in Box2D_v1.4.0/Box2D/Examples/TestBed/Tests: Makefile
diff -r Box2D_v1.4.0/Box2D/Examples/TestBed/Tests/PolyCollision.h fresh2/Box2D_v1.4.0/Box2D/Examples/TestBed/Tests/PolyCollision.h
24,26c24
< //necessary change to compile under GNU/Linux
< //#include "freeglut/GL/glut.h"
< #include <GL/glut.h>
---
> #include "freeglut/GL/glut.h"
Only in Box2D_v1.4.0/Box2D: Makefile
Only in Box2D_v1.4.0/Box2D/Source/Collision: Makefile
diff -r Box2D_v1.4.0/Box2D/Source/Common/b2Math.h fresh2/Box2D_v1.4.0/Box2D/Source/Common/b2Math.h
29,31c29
<       //necessary change to compile under GNU/Linux
< //    return _finite(x) != 0;
<       return finite(x) != 0;
---
>       return _finite(x) != 0;
Only in Box2D_v1.4.0/Box2D/Source/Common: Makefile
Only in Box2D_v1.4.0/Box2D/Source/Dynamics/Contacts: Makefile
Only in Box2D_v1.4.0/Box2D/Source/Dynamics/Joints: Makefile
Only in Box2D_v1.4.0/Box2D/Source/Dynamics: Makefile
Only in Box2D_v1.4.0/Box2D/Source: Makefile
I'm wrapped up in CCD now. I'll take a look at this for 2.0.1. Thanks!

I think we discussed using CMake a while back. Would this work for you?
I only used cmake once to compile a program. I don't know how it works at all. 😳
But what I could do eventually are devpaks usable with DevC++ and Code::Blocks.

If I manage to compile box2d with an IDE, I should have a tarball with configure/make/make install automatically.
Then if there's an autotools->cmake converter, it's doable.

So, basically, I could do it if I have the time and learn how to do it.
But right now, I can't. ^^

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