Android NDK生成导致错误

Android NDK生成导致错误,android,android-ndk,Android,Android Ndk,很长一段时间以来,我一直在尝试解决这个问题,我正在使用一个名为FreeImage的库,当尝试进行NDK构建时,代码会导致以下错误 我的源代码可以从 copy.html“>http://www.4shared.com/zip/1C3vpLI7/android-imagefilter-ndk_copy.html 提前感谢您的宝贵努力- tribute.cpp+0x8): undefined reference to `std::ios_base::Init::Init()' ImfChromatic

很长一段时间以来,我一直在尝试解决这个问题,我正在使用一个名为FreeImage的库,当尝试进行NDK构建时,代码会导致以下错误 我的源代码可以从

copy.html“>http://www.4shared.com/zip/1C3vpLI7/android-imagefilter-ndk_copy.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)
我的应用程序.mk

APP_OPTIM := release
APP_PLATFORM := android-8
APP_STL := gnustl_static
APP_CPPFLAGS += -frtti 
APP_CPPFLAGS += -fexceptions
APP_CPPFLAGS += -DANDROID
APP_ABI:= armeabi

我认为您在gcc/NDK中看到了一个bug,它在Linux、Cygwin和Windows(非Cygwin)上的表现略有不同

下面是我为修复它所做的工作(适用于Linux和我的一位盲人开发人员,他必须使用Cygwin)… -从Application.mk中删除写着,
APP\u STL:=gnustl\u static
的行(它在NDK中被破坏;此外,在Linux Cygwin和Windows上被破坏的方式略有不同) -在Andriod.mk中添加三行,即,
LOCAL_C_include:=$(NDK_ROOT)/sources/cxx stl/gnu libstdc++/4.6/include
LOCAL\u C\u INCLUDES+=$(NDK\u 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
^^^^此行必须在美元(本地\u LDLIBS)的末尾附近
上述内容将实现“APP\u STL:=gnustl\u static”的功能“在你的Application.mk中应该是这样的。

你的Android.mk和Application.mk文件是什么样子的?@Michael…请查看编辑,看起来像libfreeimage。a编译错误。试着用你正在编译的Android NDK完全编译它。或者更好——不要使用静态库。包括FreeImage的Android.ml makefile,并与您的代码一起编译-这将保证您不会遇到此类问题。您构建ABI的目的是什么?我看到一些未定义的引用,表明某些代码是为ARM构建的,但您似乎使用的是x86工具链。@Martins Mozeiko…您好,我一直在使用下载的libfreeimage.a版本。如何使代码正常工作?