3

我一直试图安静地解决这个问题很长时间,我正在使用一个名为 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()'

我的安卓.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
4

1 回答 1

2

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

这是我为修复它所做的工作(适用于 Linux 和我的一位盲人并且必须使用 Cygwin 的开发人员)......

- 从您的 Application.mk 中删除该行APP_STL := gnustl_static(它在 NDK 中损坏;此外,它在 Linux Cygwin、Windows 上的损坏略有不同)

- 在 Andriod.mk 中添加三行,表示^^^此行必须在 $(LOCAL_LDLIBS) 的末尾附近
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

上述内容将完成您的 Application.mk 中应该具有的“APP_STL := gnustl_static”。

于 2013-05-20T15:50:51.067 回答