title: Android NDK linker error 'Undefined reference to std::ios_base' when using FreeImage
body: <p>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).</p>
  
  <p>When I compile and link my project I get a lot of linker errors along the lines of:</p>
  
  <p><code>
  ../../../lib/ndk/armeabi-v7a/libfreeimage.a(ImfTimeCodeAttribute.o): In function <code>global constructors keyed to ImfTimeCodeAttribute.cpp':
  ImfTimeCodeAttribute.cpp:(.text+0x28): undefined reference to</code>std::ios_base::Init::Init()'
  </code></p>
  
  <p>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.</p>
  
  <p>Any help would be greatly appreciated. </p>
  
  <p>Android.mk:</p>
  
  <pre>
  <code>
  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)
  </code>
  </pre>