Thursday, October 18, 2012

Solving Box2D build issues on Ubuntu 10.04

While building Box2D on a Ubuntu 10.04 system I faced many problems. After lot googling and trying different solutions I finally built it successfully. The solutions are scattered on the net. I have collected it in this blog at one place because i think i have faced all build problems :) .  

1. Download Box2D from here :
2. Read the Building.txt file that comes with the download carefully.
3. I faced problem while building the cod with premake. The error message was :
 The problem was that the vpaths are added in the premake 4.4 version only. Hence the problem. Read this: This solved 'vpaths' problem.

3. Another error you may face is :

==== Building HelloWorld (debug) ==== Creating obj/Debug/HelloWorld make[1]: *** No rule to make target `../../HelloWorld/Helloworld.cpp', needed by `obj/Debug/HelloWorld/Helloworld.o'. Stop. make: *** [HelloWorld] Error 2

This is a typo.Read this : This problem will also be solved.

4. Again after successful building of HelloWorld. You may face below problem :

==== Building HelloWorld (debug) ==== HelloWorld.cpp Linking HelloWorld ==== Building Testbed (debug) ==== Creating obj/Debug/Testbed Render.cpp Test.cpp Main.cpp TestEntries.cpp Linking Testbed /usr/bin/ld: cannot find -lGLUT collect2: ld returned 1 exit status make[1]: *** [bin/Debug/Testbed] Error 1 make: *** [Testbed] Error 2

Read this to solve the issue:

5. Cmake problem :

[ 29%] Built target Box2D
[ 59%] Built target Box2D_shared
[ 60%] Built target HelloWorld
[ 61%] Building C object freeglut/CMakeFiles/freeglut_static.dir/freeglut_callbacks.c.o
In file included from /home/gaurav/Documents/me/Box2D_v2.2.1/freeglut/freeglut_callbacks.c:29:
/home/user/Box2D_v2.2.1/freeglut/freeglut_internal.h:111:39: error: X11/extensions/XInput.h: No such file or directory
make[2]: *** [freeglut/CMakeFiles/freeglut_static.dir/freeglut_callbacks.c.o] Error 1
make[1]: *** [freeglut/CMakeFiles/freeglut_static.dir/all] Error 2
make: *** [all] Error 2

/usr/include/X11/extensions/XInput.h is present in Ubuntu 10.04 as /usr/include/X11/extensions/XI.h. So just go to Box2D_v2.2.1/freeglut/freeglut_internal.h. Inside check the the line where error occurred : include X11/extensions/XInput.h . Just rename it to include X11/extensions/XI.h.

Try to "make" again. And when you see the below lines :

Linking CXX executable Testbed
[100%] Built target Testbed

Congratulations. The Box2D build is complete successfully.

No comments: