我正在尝试构建 freeimage 并将其链接到 android 项目。我已经很接近了,但我遇到了该库中的一些链接器错误。
我正在使用这个仓库:https://github.com/jamcar23/FreeImage-Android/blob/master/jni/freeimage/Android.mk https://github.com/jamcar23/FreeImage-Android/blob/master/jni/freeimage/Android.mk
Freeimage 使用内部 NDK 库“cpufeatures”来使用 xeon 芯片组功能。在项目的“android.mk”中,有对 cpufeatures 库的引用:
LOCAL_STATIC_LIBRARIES := cpufeatures
我的库静态链接到这个库,还在该项目的 android.mk 的 LOCAL_STATIC_LIBRARIES 语句中包含 cpufeatures:
LOCAL_STATIC_LIBRARIES := tinyxml freetype2 bullet freeimage cpufeatures
同样在我的 android.mk 中,我像这样链接 freeimage:
#####FREEIMAGE_LIBRARY_DECLARATION##########
include $(CLEAR_VARS)
LOCAL_PATH = $(TPLIBROOT)/FreeImage-Android
LOCAL_MODULE := freeimage
LOCAL_EXPORT_C_INCLUDES := include
LOCAL_SRC_FILES := obj/local/$(TARGET_ARCH_ABI)/libFreeImage.a
include $(PREBUILT_STATIC_LIBRARY)
###############################################
注意到我之前关于 NDK 的问题,应该处理特定的架构(我已经使用所有可用的架构构建了 freeimage)
freeimage .a 和 .so 库似乎构建得很好,但是在构建 .so 时链接到我的库时,我收到此错误:
[armeabi-v7a] SharedLibrary : libAnthracite.so
jni/freeimage/Source/LibWebP/./src/dsp/dsp.cpu.c:108: error: undefined reference to 'android_getCpuFamily'
jni/freeimage/Source/LibWebP/./src/dsp/dsp.cpu.c:109: error: undefined reference to 'android_getCpuFeatures'
jni/freeimage/Source/LibWebP/./src/dsp/dsp.dec.c:745: error: undefined reference to 'VP8DspInitNEON'
这很奇怪,因为两个库都链接了 cpufeatures,所以它确实应该在那里。
我宣布
APP_PLATFORM := android-14
APP_STL := gnustl_static
在两个项目的 application.mk 文件中。
另外,我尝试将“LOCAL_STATIC_LIBRARIES”放置在文件中的不同位置,并以不同的顺序链接库,尽管这只是猜测。
有谁知道可能导致这些链接器错误的原因是什么?