I am trying to statically link against the open frameworks build of libfreeimage.a for the Android NDK (using the native-activity sample as a template).
When I compile and link my project I get a lot of linker errors along the lines of:
../../../lib/ndk/armeabi-v7a/libfreeimage.a(ImfTimeCodeAttribute.o): In function
global constructors keyed to ImfTimeCodeAttribute.cpp':
ImfTimeCodeAttribute.cpp:(.text+0x28): undefined reference to
std::ios_base::Init::Init()'
I believe this is a scoping problem that can be fixed by either adding a namespace to the code or using g++ over gcc. I thought -lstdc++ would fix the problem but it did not.
Any help would be greatly appreciated.
Android.mk:
LOCAL_PATH := $(call my-dir)/tmp
include $(CLEAR_VARS)
LOCAL_MODULE := androidapp
LOCAL_CFLAGS := -DFREEIMAGE_LIB\
-DANDROID_NDK \
-DDISABLE_IMPORTGL \
-mfpu=vfp -mfloat-abi=softfp \
-ffast-math -O3 -DFPM_ARM
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM -lstdc++ -ldl
LOCAL_STATIC_LIBRARIES := android_native_app_glue
LOCAL_LDLIBS += ../../../lib/ndk/armeabi-v7a/libfreeimage.a
LOCAL_ARM_MODE := arm
SRC-FILES := $(wildcard tmp/*.c*)
SRC-FILES := $(SRC-FILES:tmp/%=%)
LOCAL_SRC_FILES += $(SRC-FILES)
APP_OPTIM := release
APP_ABI := armeabi-v7a
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)
Finally figured this out - for anyone else with the same problem, the fix is to add a module for the library and then include the library:
LOCAL_PATH := $(call my-dir)/tmp
include $(CLEAR_VARS)
LOCAL_MODULE := freeimage
LOCAL_SRC_FILES := ../../../../lib/ndk/armeabi-v7a/libfreeimage.a
LOCAL_EXPORT_C_INCLUDES := ../../../../lib/inc
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := androidapp
LOCAL_CFLAGS := -DFREEIMAGE_LIB\
-DANDROID_NDK \
-DDISABLE_IMPORTGL \
-mfpu=vfp -mfloat-abi=softfp \
-ffast-math -O3 -DFPM_ARM
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM -ldl -lstdc++
LOCAL_STATIC_LIBRARIES := android_native_app_glue
LOCAL_STATIC_LIBRARIES += freeimage
LOCAL_ARM_MODE := arm
SRC-FILES := $(wildcard tmp/*.c*)
SRC-FILES := $(SRC-FILES:tmp/%=%)
LOCAL_SRC_FILES += $(SRC-FILES)
APP_OPTIM := release
APP_ABI := armeabi-v7a
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)