Box2D & CDT for Android NDK

133 views
Skip to first unread message

Doug Schaefer

unread,
Jul 24, 2009, 12:17:13 PM7/24/09
to android-ndk
I have yet another port of Box2D available. This one is more a showcase of using the Eclipse CDT for NDK development. But I'm using it to make some games so it should be useful for others as well.
 
It's available on github:
 
 
Please read the README. The android.mk file in the box2d is the real Makefile (I left the old one there). I've only tested this on Windows. And I'm using the latest Galileo Eclipse SDK (3.5) and CDT (6.0) with the latest Android plug-in.
 
I've ported the Hello World sample from box2d into an Android app using the Android Eclipse plug-in along side the CDT. I wrote my own Makefile to allow the native code to be co-resident in the Android project. Change the ANDROID_NDK_BASE variable to point to your NDK install. I'm sure there are assumptions made there that limit the flexibility. Also the CDT projects are set up assuming cygwin is in C:\cygwin. That can be changed in the C++ Build environment settings project properties.
 
Note that I don't have debug support for the CDT here yet. That'll require some CDT plug-in development. We could also use some automation to add native support to Android projects to set up the CDT. No promises, but I know I could use these. I'll add documentation of the steps I went through at least so you don't need to reverse engineer them :).
 
Let me know if you have any questions or run into problems. I'll keep updating the github repo with any fixes or README updates as needed.
 
Cheers,
Doug.
 

ehclo...@gmail.com

unread,
Jul 25, 2009, 2:41:39 PM7/25/09
to android-ndk
Great. I've just spent the last hour on Fantastic Contraption learning
about box2d.

-E

Romain MOURA

unread,
Aug 11, 2009, 9:33:48 AM8/11/09
to android-ndk
Hi !
It seem's te be a great piece of code, but i can't build it, I got
this error:


**** Build of configuration Default for project TestBox2D ****

make all
/home/romain/Android/android-ndk-1.5_r1/build/prebuilt/linux-x86/arm-
eabi-4.2.1/bin/arm-eabi-ld \
-nostdlib -shared -Bsymbolic --no-undefined \
-o obj/libtest.so obj/test.o -L../box2d/lib/android -lbox2d \
-L/home/romain/Android/android-ndk-1.5_r1/build/platforms/
android-1.5/arch-arm/usr/lib \
-llog -lc -lstdc++ -lm \
/home/romain/Android/android-ndk-1.5_r1/build/prebuilt/linux-x86/arm-
eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/interwork/libgcc.a \

/home/romain/Android/android-ndk-1.5_r1/build/prebuilt/linux-x86/arm-
eabi-4.2.1/bin/arm-eabi-ld: cannot find -lbox2d
make: *** [obj/libtest.so] Erreur 1



Any idea ?

Thanks

David Turner

unread,
Aug 11, 2009, 1:14:28 PM8/11/09
to andro...@googlegroups.com
It means that the linker didn't find libbox2d.so in ../box2d/lib/android or the sysroot.
You are probably missing some kind of dependency.

Doug Schaefer

unread,
Aug 11, 2009, 9:38:48 PM8/11/09
to andro...@googlegroups.com
Yes, check the lib/android folder in the box2d project. You should find libbox2d.a there. If not, make sure the box2d project is built first. There is a project dependency from the Test to the box2d project which should have force that, but I do hear reports of that not always being the case.

Thanks,
Doug.
Reply all
Reply to author
Forward
0 new messages