0

I am making a library that I aim to use in both android and windows. For windows, using Visual Studio 2010, it compiles, links and runs fine.

For Android, I am using the ndk-build script with android-ndk-r7 (which uses gcc 4.4.3). I am getting several of these linker errors:

./obj/local/armeabi-v7a/libjonsengine.a(RenderManagerImpl.o):(.data.rel.ro._ZTI1
4IRenderManager[typeinfo for IRenderManager]+0x0): undefined reference to `vtabl
e for __cxxabiv1::__si_class_type_info'
./obj/local/armeabi-v7a/libjonsengine.a(RenderManagerImpl.o):(.data.rel.ro._ZTI1
2IBaseManager[typeinfo for IBaseManager]+0x0): undefined reference to `vtable fo
r __cxxabiv1::__class_type_info'
./obj/local/armeabi-v7a/libjonsengine.a(RenderManagerImpl.o):(.data.rel.ro+0x34)
: undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
./obj/local/armeabi-v7a/libjonsengine.a(LogManagerImpl.o):(.data.rel.ro._ZTI11IL
ogManager[typeinfo for ILogManager]+0x0): undefined reference to `vtable for __c
xxabiv1::__si_class_type_info'
./obj/local/armeabi-v7a/libjonsengine.a(LogManagerImpl.o):(.data.rel.ro+0x38): u
ndefined reference to `vtable for __cxxabiv1::__si_class_type_info'
./obj/local/armeabi-v7a/libjonsengine.a(MemoryManagerImpl.o):(.data.rel.ro._ZTI1
4IMemoryManager[typeinfo for IMemoryManager]+0x0): undefined reference to `vtabl
e for __cxxabiv1::__si_class_type_info'
./obj/local/armeabi-v7a/libjonsengine.a(MemoryManagerImpl.o):(.data.rel.ro+0x40)
: undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libandroidgame.so] Error 1

Here is my Android.mk:

LOCAL_PATH:= $(call my-dir)
TOP_PATH := $(LOCAL_PATH)

include $(CLEAR_VARS)
# Main engine
LOCAL_MODULE    := jonsengine
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include/ \
                    $(LOCAL_PATH)/../include/Core/ \
                    $(LOCAL_PATH)/../interface/ \
                    $(LOCAL_PATH)/../include/Render/ \
                    $(LOCAL_PATH)/../include/Utils/ \
                    $(LOCAL_PATH)/../include/Memory/

# Core
LOCAL_SRC_FILES :=  ../src/Core/Engine.cpp

# Rendering
LOCAL_SRC_FILES +=  ../src/Render/RenderManagerImpl.cpp

# Utils
LOCAL_SRC_FILES +=  ../src/Utils/LogManagerImpl.cpp \
                    ../src/Utils/PortableTime.cpp

# Memory
LOCAL_SRC_FILES +=  ../src/Memory/MemoryManagerImpl.cpp \
                    ../src/Memory/MemoryPool.cpp \
                    ../src/Memory/dlmalloc.c

LOCAL_CFLAGS := -DSTRUCT_MALLINFO_DECLARED
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_EXPORT_CFLAGS := $(LOCAL_CFLAGS)
LOCAL_LDLIBS    := -lGLESv2 -llog

include $(BUILD_STATIC_LIBRARY)



# Testing library
include $(CLEAR_VARS)

LOCAL_MODULE    := jonsenginetests
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../Tests/ \
                    $(LOCAL_PATH)/../Tests/Memory/ \
                    $(LOCAL_PATH)/../Tests/Core/

LOCAL_SRC_FILES :=  ../Tests/TestManager.cpp \
                    ../Tests/Memory/MemoryManagerTest.cpp \
                    ../Tests/TestClass1.cpp

LOCAL_CFLAGS :=
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_EXPORT_CFLAGS := $(LOCAL_CFLAGS)
LOCAL_STATIC_LIBRARIES := jonsengine
LOCAL_LDLIBS    :=-llog

include $(BUILD_STATIC_LIBRARY)

I can't divine the meaning nor the cause of that error. Anyone can shed some light on this? As I mentioned it works fine with VC++.

EDIT2:

Updated the error log. Does that help anything?

When I use "nm RenderManagerImpl.o" I get 'V' symbols and "00000000" addresses for '_ZTI4IRenderManager' for example.

EDIT3: It seems if I make jonsenginetests into a shared library rather than static it compiles. What does that imply?

Thanks

KaiserJohaan
  • 9,028
  • 20
  • 112
  • 199

1 Answers1

0

This is a bit of a guess but that class name sounds like it might be to do with RTTI, which is disabled by default in the android NDK.

Assuming I'm right, you can enable RTTI for your application by adding the following to your Android.mk file:

LOCAL_CPP_FEATURES := rtti

For more information, I'd recommend looking in docs\ANDROID-MK.html and docs\CPLUSPLUS-SUPPORT.html in the android NDK

It could also be that you're using a part of the standard library that isn't supported by the android NDK. It's default support is fairly limited. You can change what it uses by supplying APP_STL in Application.mk. For example:

APP_STL := gnustl_static
obmarg
  • 9,369
  • 36
  • 59
  • @KaiserJohaan Ah bad guess then I suppose. I've updated my answer with another possibility. It might be just as wrong though. – obmarg Feb 11 '12 at 20:53
  • Was already using it, didn't work either :p those errors are really cryptic. I wonder why it links on windows but not with android/gcc? – KaiserJohaan Feb 11 '12 at 20:59