Compiling on Linux(Ubuntu)

Hi,

For the time a i am using Ubuntu. I need help how to link box2D while compiling a program in terminal, i need a thorough tutorial or help. I have installed libraries for box2D from Ubuntu Software Center. What Next?
I had also a lot of problems with it. So I converted Box2D from a library to a project by changing all the include statements.
eg:
Code:
#include <Box2D/Dynamics/Body.h>

becomes
Code:
#include <../Body.h>

The converted source is attached. Just put it into your project and include like this:
Code:
#include "Box2D/Box2D.h"

It is version 2.0.1, I think... (The latest I could find on google code (2010/06/20))
@mcourteaux - your solution works perfectly! I was banging my head against this for the last day or so trying to get a good install, and your totally killed it. THANK YOU.

For the record I am running Xcode on a Mac running Leopard.

And I love physics. 😀
That is a bit ironic. Box2D has absolute paths at the request of Linux programmers.
I use Fedora 11 and I have been able to compile and install Box2D 2.1.2 without changing the sources or the makefiles.

I do this to build:
Code:
cd Box2D/Build
cmake -DBOX2D_VERSION=2.1.2 \
    -DBOX2D_INSTALL=ON \
    -DBOX2D_INSTALL_DOC=ON \
    -DBOX2D_BUILD_SHARED=ON \
    -DBOX2D_BUILD_STATIC=OFF \
    -DBOX2D_BUILD_EXAMPLES=OFF \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_VERBOSE_MAKEFILE=ON \
    ..
make

Then I do this to install to /usr/local:
Code:
make preinstall
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -P cmake_install.cmake

I have used a similar procedure to make my own RPM package (which installs under /usr).

In my game code, I use this: #include <Box2D/Box2D.h>

If the library is installed under /usr/local, the compiler would need to receive "-I/usr/local/include" for the includes and "-L/usr/local/lib -lBox2D" for linking.

My RPM package installs a .pc file that allows the pkg-config command to provide these compiler and linker switches.

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