Android NDK 链接器错误“未定义对 std::ios_base 的引用”使用 FreeImage 时
我正在尝试静态链接 Android NDK 的 libfreeimage.a 开放框架构建(使用本机活动示例作为模板)。
当我编译和链接我的项目时,我收到很多链接器错误,如下所示:
../../../lib/ndk/armeabi-v7a/libfreeimage.a(ImfTimeCodeAttribute.o):在函数
全局构造函数中键入 ImfTimeCodeAttribute.cpp': ImfTimeCodeAttribute.cpp:(.text+0x28): 对 std::ios_base::Init::Init()' 的未定义引用
我相信这是一个范围问题,可以通过在代码中添加命名空间或使用 g++ 而不是 gcc 来解决。我以为 -lstdc++ 可以解决问题,但事实并非如此。
任何帮助将不胜感激。
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)
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':
std::ios_base::Init::Init()'
ImfTimeCodeAttribute.cpp:(.text+0x28): undefined reference to
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于弄清楚了 - 对于有同样问题的其他人,解决方法是为库添加一个模块,然后包含该库:
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: