Problems compiling Hello World (Android)

Discuss issues specific to miscellaneous ports of Box2D
partyk1d24
Posts: 5
Joined: Tue Jun 18, 2013 7:16 am

Problems compiling Hello World (Android)

Postby partyk1d24 » Tue Jun 18, 2013 7:23 am

So I am working on Porting Box2D for Android, mainly just to work on my porting skills.

The Box2D compiles fine, and I include the libs in the HelloWorld app, however, when I try to compile I see a bunch of errors here are some examples...

Code: Select all

in function main:./HelloWorld.cpp:38: error: undefined reference to 'b2World::b2World(b2Vec2 const&)
in function main:./HelloWorld.cpp:47: error: undefined reference to 'b2World::CreateBody(b2BodyDef const*)'
etc


Also it appears some functions work and some do not for example

Code: Select all

b2Vec2 gravity(0.0f, -10.0f);


Doesn't seem to have an issue. I know I am including the Box2d.h because if I comment out the include line I get the following...

fatal error: Box2D/Box2D.h: No such file or directory


Anyone know what I am missing here?

irresistible force
Posts: 1991
Joined: Tue Jun 24, 2008 8:25 pm
Location: Tokyo
Contact:

Re: Problems compiling Hello World (Android)

Postby irresistible force » Tue Jun 18, 2013 9:13 am

partyk1d24 wrote:... I include the libs

It would seem that you are not in fact doing that, at least not the one you need. You would need to either compile Box2D as a library and add it to the libs to be linked with, or include all the Box2D source code in your application directly.

partyk1d24
Posts: 5
Joined: Tue Jun 18, 2013 7:16 am

Re: Problems compiling Hello World (Android)

Postby partyk1d24 » Tue Jun 18, 2013 10:22 am

So it is a bit complicated but yes you are correct, I thought I was including the libraries and was not.

If anyone else has this issue here is my Android.mk

Code: Select all

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := box2D-prebuilt
LOCAL_SRC_FILES := ../Box2D/libs/$(TARGET_ARCH_ABI)/libbox2D.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/..
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := box2DHello
# LOCAL_C_INCLUDES := $(LOCAL_PATH)/..
LOCAL_SRC_FILES := \
        $(subst $(LOCAL_PATH)/,, \
        $(wildcard $(LOCAL_PATH)/*.c) \
        $(wildcard $(LOCAL_PATH)/*.cpp))
LOCAL_LDLIBS := -lm -llog
LOCAL_SHARED_LIBRARIES := box2D-prebuilt
include $(BUILD_SHARED_LIBRARY)


Return to “Miscellaneous”



Who is online

Users browsing this forum: No registered users and 1 guest