需要"cpufeatures"的外部NDK库的链接器错误 [英] Linker errors with external NDK library that needs 'cpufeatures'

查看:697
本文介绍了需要"cpufeatures"的外部NDK库的链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建freeimage并将其链接到android项目.我已经关闭,但是我遇到了该库中的一些链接器错误.

I'm trying to build and link freeimage to an android project. I'm close but I'm tripping up on some linker errors from that library.

我正在使用此存储库: https: //github.com/jamcar23/FreeImage-Android/blob/master/jni/freeimage/Android.mk

I'm using this repo: https://github.com/jamcar23/FreeImage-Android/blob/master/jni/freeimage/Android.mk

Freeimage使用内部NDK库"cpufeatures"来使用至强芯片组功能.在项目的"android.mk"中,有对cpufeatures库的引用:

Freeimage uses the internal NDK library 'cpufeatures' to use xeon chipset features. In the project's 'android.mk', there's a reference to the cpufeatures library:

LOCAL_STATIC_LIBRARIES := cpufeatures

与我的库静态链接的该库,在该项目的android.mk中的LOCAL_STATIC_LIBRARIES语句中也包含cpufeatures:

and my library, which statically links to this one, also includes cpufeatures in its LOCAL_STATIC_LIBRARIES statement in that project's android.mk:

LOCAL_STATIC_LIBRARIES := tinyxml freetype2 bullet freeimage cpufeatures

也在我的android.mk中,我像这样链接freeimage:

also in my android.mk, I link freeimage like this:

#####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)

which, taking note of a previous question I had about the NDK, should take care of specific architectures (I've build freeimage using all available architectures)

freeimage .a和.so库似乎可以正常构建,但是在构建.so时链接到我的库时,出现此错误:

freeimage .a and .so libraries appear to build fine but on linking to my library when building the .so, I get this error:

[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,因此它确实应该存在.

which is odd as both libraries do link cpufeatures, so it really ought to be there.

我要声明

APP_PLATFORM := android-14
APP_STL := gnustl_static

两个项目的application.mk文件中的

. 另外,我尝试将"LOCAL_STATIC_LIBRARIES"放置在文件中的不同位置,并以不同的顺序链接库,尽管这只是猜测. 有人知道什么可能导致这些链接器错误吗?

in the application.mk files for both projects. Also, I've tried placing 'LOCAL_STATIC_LIBRARIES' in different positions in the files and linking libraries in different orders, although that's just guesswork. Does anybody know what might be causing these linker errors?

推荐答案

我终于通过确保我使用的所有四个第三方库的所有"application.mk"文件都共享一个公共库来使它正常工作看起来像这样的文件:

I finally got it to work by ensuring that all of my 'application.mk' files for all four of the third party libraries I was using shared a common base file that looks like this:

APP_PLATFORM := android-15
APP_STL      := c++_static
APP_ABI      := all    
APP_OPTIM    := release
APP_SHORT_COMMANDS := true

这使得使它们保持一致更加容易,从而确保它们都是基于相同的库构建的. 另外,我将STL实现从'gnustl_static'更改为'c ++ _ static'

Which makes keeping them in line easier, ensuring they're all built against the same libraries. Also, I changed the STL implementation from 'gnustl_static' to 'c++_static'

这篇关于需要"cpufeatures"的外部NDK库的链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆