Building for Code::Blocks

Okay, so after hours of searching and downloads tons of different source files, I think I've gotten close, but I'm completely lost on what to do next, or whether it even worked or not.

I'm using Code::Blocks 10.05, Windows 7.

Now I managed to get box2d working for Microsoft Visual C++, but I'm trying to get it to work for Code Blocks.

I downloaded the project files from here: http://www.iforce2d.net/b2dtut/setup-windows

And it didn't work as stated, so I followed the solution from here: http://stackoverflow.com/questions/6976 ... 62#6977162

And I managed to build the library successfully, it even created a directory called Library with two files "libBox2d.a" and a folder "mingw" with a file "libBox2d_d.a".

So my question is..what exactly do I do next? Where do I put these files and how do I start using them?

Any help is appreciated, thanks!
If you are trying to build the library itself, you've already built it.
If you wanted to run the testbed, you'll have to do the same thing you did for the Engine project, for all the other projects in the workspace. The files to add are in the folders of the same name as each project. You can ignore the HelloWorld one.

Incidentally, what problem did you get with the first project files? Did you try both versions of the project files on that page? The paths are important so you would need to keep the .cbp files in the same location as the originals (overwrite them).
Thanks for the reply irresistible force!

Actually, I didn't really catch that the words "Please use these to replace the .workspace and .cbp files in the Codeblocks folder." meant what that other link was saying. Excuse my confused-ness.

That did shed some light on the situation though, so what if I, instead of running the test bed, wanted to run box2d in a project of mine? What would I need to add to the directory or import or what? I tried just throwing the "Engine" project file that I managed to build successfully in my work folder, but since this was a project and not like a class or library that I could handily import, I'm just confused as to what the next step is to link this to another project.

Again, thanks!
Compiling with a static-link library is a standard procedure that has been around for decades, and is nothing specific to Box2D. If you are coming from some other coding environment I suggest you take a few steps back and spend a little time to cover the basics first.

The basics are:
- include the header file in your program source code so that it knows what functions and classes exist in Box2D, this will enable you to compile each of your source code files into a .o object file. These object files do not contain the actual Box2D functions, they just know that the functions exist 'somewhere'.
- tell the linker that the Box2D lib (libBox2d.a) should be linked to, this will allow it to link the function calls from your object files to their actual implementation in libBox2D.a

This is two steps but typically an IDE like Code::blocks will do them in one go for you, so it might feel like a single step.

The first of these is done simply by #include <Box2D/Box2D.h> in the source code.
The second is done by specifying either of these formats:

path/to/theLibYouBuilt/libBox2d.a
or
-Lpath/to/theLibYouBuilt -lBox2D

on the command line for the compiler, if you are using the command line directly. Any worthwhile IDE will issue these command line instructions for you but it still needs to know what libraries should be used.

For Code::blocks:
Right click the project name and choose 'Properties...', then 'Project's build options...', then 'Linker settings'.
The first format shown above uses the full path and file name directly and could be added into the 'Link libraries' list.
The second format could be done by entering just 'Box2D' into the link libraries list, and adding the path to where the .a file is in the 'Search directories' -> 'Linker' list.
The second format is mainly useful when you have many libraries in the same folder, and is more convenient when you might want to move that folder later.
Thank you very much for the help irresistible force! It works now!

I added both libBox2d.a and libBox2d_d.a

The first is for the release version and the second is the debug version I assume?

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