我一直试图解决这个问题很长一段时间,我正在使用一个名为FreeImage的库,当尝试进行NDK构建时,代码会导致以下错误 我的来源可以从
下载copy.html“> HTTP://www.4shared.com/zip/1C3vpLI7/android-imagefilter-ndk_ 复制的.html 提前感谢您的宝贵努力 -
tribute.cpp+0x8): undefined reference to `std::ios_base::Init::Init()'
ImfChromaticitiesAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfChromaticitiesAttribute.cpp+0x24): undefined reference to `std::ios_base::Init::~Init()'
/home/flock/ANDROID/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Dwarf Error: mangled line number section.
./obj/local/armeabi/libfreeimage.a(ImfCompressionAttribute.o): In function `_GLOBAL__sub_I_ImfCompressionAttribute.cpp':
ImfCompressionAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfCompressionAttribute.cpp+0x8): undefined reference to `std::ios_base::Init::Init()'
ImfCompressionAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfCompressionAttribute.cpp+0x24): undefined reference to `std::ios_base::Init::~Init()'
./obj/local/armeabi/libfreeimage.a(ImfCompressor.o): In function `Imf::newCompressor(Imf::Compression, unsigned int, Imf::Header const&)':
ImfCompressor.cpp:(.text._ZN3Imf13newCompressorENS_11CompressionEjRKNS_6HeaderE+0x10): undefined reference to `__gnu_thumb1_case_uqi'
ImfCompressor.cpp:(.text._ZN3Imf13newCompressorENS_11CompressionEjRKNS_6HeaderE+0xb8): undefined reference to `__cxa_end_cleanup'
./obj/local/armeabi/libfreeimage.a(ImfCompressor.o):(.ARM.extab.text._ZN3Imf13newCompressorENS_11CompressionEjRKNS_6HeaderE+0x0): undefined reference to `__gxx_personality_v0'
./obj/local/armeabi/libfreeimage.a(ImfCompressor.o): In function `Imf::newTileCompressor(Imf::Compression, unsigned int, unsigned int, Imf::Header const&)':
ImfCompressor.cpp:(.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0x12): undefined reference to `__gnu_thumb1_case_uqi'
ImfCompressor.cpp:(.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0x64): undefined reference to `__cxa_allocate_exception'
ImfCompressor.cpp:(.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0x8a): undefined reference to `__cxa_throw'
ImfCompressor.cpp:(.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0xe4): undefined reference to `__cxa_end_cleanup'
./obj/local/armeabi/libfreeimage.a(ImfCompressor.o):(.ARM.extab.text._ZN3Imf17newTileCompressorENS_11CompressionEjjRKNS_6HeaderE+0x0): undefined reference to `__gxx_personality_v0'
./obj/local/armeabi/libfreeimage.a(ImfCompressor.o): In function `_GLOBAL__sub_I_ImfCompressor.cpp':
ImfCompressor.cpp:(.text.startup._GLOBAL__sub_I_ImfCompressor.cpp+0x8): undefined reference to `std::ios_base::Init::Init()'
ImfCompressor.cpp:(.text.startup._GLOBAL__sub_I_ImfCompressor.cpp+0x24): undefined reference to `std::ios_base::Init::~Init()'
./obj/local/armeabi/libfreeimage.a(ImfCompressor.o):(.data.rel.ro+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
/home/flock/ANDROID/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Dwarf Error: mangled line number section.
./obj/local/armeabi/libfreeimage.a(ImfConvert.o): In function `_GLOBAL__sub_I_ImfConvert.cpp':
ImfConvert.cpp:(.text.startup._GLOBAL__sub_I_ImfConvert.cpp+0x8): undefined reference to `std::ios_base::Init::Init()'
ImfConvert.cpp:(.text.startup._GLOBAL__sub_I_ImfConvert.cpp+0x24): undefined reference to `std::ios_base::Init::~Init()'
/home/flock/ANDROID/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Dwarf Error: mangled line number section.
./obj/local/armeabi/libfreeimage.a(ImfDoubleAttribute.o): In function `_GLOBAL__sub_I_ImfDoubleAttribute.cpp':
ImfDoubleAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfDoubleAttribute.cpp+0x8): undefined reference to `std::ios_base::Init::Init()'
ImfDoubleAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfDoubleAttribute.cpp+0x24): undefined reference to `std::ios_base::Init::~Init()'
/home/flock/ANDROID/android-ndk-r8/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: Dwarf Error: mangled line number section.
./obj/local/armeabi/libfreeimage.a(ImfEnvmapAttribute.o): In function `_GLOBAL__sub_I_ImfEnvmapAttribute.cpp':
ImfEnvmapAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfEnvmapAttribute.cpp+0x8): undefined reference to `std::ios_base::Init::Init()'
ImfEnvmapAttribute.cpp:(.text.startup._GLOBAL__sub_I_ImfEnvmapAttribute.cpp+0x24): undefined reference to `std::ios_base::Init::~Init()'
我的Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:= freeimage
LOCAL_SRC_FILES :=libfreeimage.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE:= imageprocessing
LOCAL_SRC_FILES:= imageprocessing.c
LOCAL_STATIC_LIBRARIES = freeimage
LOCAL_EXPORT_C_INCLUDES := freeimage.h
LOCAL_LDLIBS:= -lm -llog -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
我的application.mk
APP_OPTIM := release
APP_PLATFORM := android-8
APP_STL := gnustl_static
APP_CPPFLAGS += -frtti
APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -DANDROID
APP_ABI:= armeabi
答案 0 :(得分:2)
我认为你看到gcc / NDK中的一个错误在Linux,Cygwin和Windows(非Cygwin)上表现得略有不同。
以下是我修复它的方法(适用于Linux以及我的一个盲人开发人员并且必须使用Cygwin)...
- 从你的Application.mk中删除说APP_STL := gnustl_static
的行(它在NDK中被破坏;而且,在Linux Cygwin,Windows上它的区别略有不同)
- 在Andriod.mk上添加三行说明,
LOCAL_C_INCLUDES := $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.6/include
LOCAL_C_INCLUDES += $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include
$(LOCAL_LDLIBS) += $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/libgnustl_static.a
^^^此行必须接近$(LOCAL_LDLIBS)的末尾
上述将完成你的Application.mk中应该有“APP_STL:= gnustl_static”的内容。