I wanted to build
Box2D v2.3.1 on my Ubuntu 14.04 machine. It took me a lot of tweaking to do it, so I thought I'd document the process here.
First I tried the instructions I found
here but I got these error messages:
CMake Error at CMakeLists.txt:29 (add_subdirectory):
add_subdirectory given source "freeglut" which is not an existing
directory.
CMake Error at CMakeLists.txt:30 (add_subdirectory):
add_subdirectory given source "glui" which is not an existing directory.
-- Configuring incomplete, errors occurred!
I searched a bit and found out that cmake is no longer supported on Box2D I had to use premake. I ran "premake gmake" in Box2D directory, but I got:
No Premake script found!
Okay. This was easy to fix. I needed premake4, not the older version in Ubuntu's repositories. I installed the latest stable version of premake from
premake website. This time, running "premake4 gmake" got me this:
/path/to/box2d-2.3.1/Box2D/premake4.lua:26: attempt to call global 'vpaths' (a nil value)
A bit more searching, and I found out I need the latest version of premake, that is the beta version. All right I got premake4.4 (beta) and this time it ran successfully. I switched to Build/gmake directory and ran "make".
At first things seemed to be going smoothly until I got lots of errors regarding undefined symbols belonging to glfw and glew. But I had the development packages for both of those installed. A lot of poking around and I managed to fix it at last. This is what I did.
- Compile and install the latest version of glfw (3.0.4) from source.
- Change this line in Build/gmake/Testbed.make:
LIBS += $(LDDEPS) -lX11 -lGL -lGLU -lglut
into this:
LIBS += $(LDDEPS) -lX11 -lGL -lGLU -lglut -lGLEW -lglfw3 -lX11 -lXxf86vm -lpthread -lXrandr -lXi
And now, at last everything compiled correctly.