Android ndk找不到atof函数 [英] Android ndk can't find atof function
问题描述
我正在尝试在我的 Android 项目中使用开源 C 库.该库使用 atof()
函数.我知道 atof()
是标准 C 库 (stdlib.h) 中定义的函数.因此,它应该在Android NDK(仿生库)上的标准C库中实现.
I am trying to use an open source C library in my Android project. This library uses the atof()
function. I know that atof()
is a function defined in the standard C library (stdlib.h). Therefore, it should be implemented in standard C library on the Android NDK (bionic library).
但是,当我尝试加载包含对此函数的调用的库时,我收到运行时错误:
But, when I try to load a library that contains calls to this function, I receive a runtime error:
java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1285]: 86 cannot locate 'atof'....
我是使用 NDK 进行 Android 开发的初学者,所以我可能只是错过了一些东西,比如标志、编译器指令等.
I am a beginner in Android development using the NDK, so maybe I just missed something like flags, compiler directives, etc.
我的 android.mk
文件是:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
LS_CPP=$(subst $(1)/,,$(wildcard $(1)/$(2)/*.c))
LOCAL_MODULE := libA
LOCAL_SHARED_LIBRARIES :=
libgmodule-2.0
libgobject-2.0
libgthread-2.0
libglib-2.0
LOCAL_SRC_FILES:= sourceFile.c
include $(BUILD_SHARED_LIBRARY
推荐答案
来自 stdlib.h;
static __inline__ double atof(const char *nptr)
{
return (strtod(nptr, NULL));
}
atof
换句话说不是一个库函数,它是一个调用 strtod
的内联函数.
atof
is in other words not a library function, it's an inline function that calls strtod
.
如果你需要通过加载库来调用,只需使用 strtod
代替.
If you need to call through loading a library, just use strtod
instead.
这篇关于Android ndk找不到atof函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!