Compiling Box2D Static Lib
1. Getting the sauce
Get the latest Box2D release from github link as the zip form.
Unzip it and put into any directory you like.
2. Modifying some stuff
Open Box2D > CMakeLists.txt
, as below :
Then remove this few lines including glui, freeglut and test bed into the compilation, so that you won't need to add them in, as below :
Then save it.
Then head to Box2D > Box2D > CMakeLists.txt
, add this line on top :
cmake_minimum_required(VERSION 3.10)
You can change to your version of cmake also.
3. Configure Cmake and generating
Open cmake-gui and set the source and target path, following your box2d directory :
Then, click Configure
.
Select CodeBlocks - MinGW Makefiles
.
Click okay, then you might see something like this and some errors :
Just ignore them and click Configure
again. You should see it getting configuration done like this :
If its done, just click Generate
there. A Generating done
will be logged out.
4. Compiling
Then go to Box2D > Build
,
Spawn a terminal there and run mingw32-make
Wait until it finished running.
Then go to Box2D > Build > Box2D
, you will find libBox2D.a
there, as below :
5. Using it with CodeBlock
- Put
libBox2D.a
intoMinGW > lib
. - Copy
Box2D > Box2D
, theBox2D folder
insideroot Box2D directory
into `MinGW > include'. - Then in CodeBlock, open
Settings > Compiler > Linker Settings > Add Library
and SelectMinGW > lib > libBox2D.a
.
6. Setup is done :)
Test it out, here is a test cpp from my uni course gist.
7. Why am I doing this
I am just merely trying to challenge myself to compile it and not following instructions.
8. Test ?
I tested the compiled lib with a uni provided cpp along with sfml, somehow it works without glui and freeglut.
Β―\_(γ)_/Β―
Top comments (0)