Android ndk can't find atof function

后端 未结 2 675
我寻月下人不归
我寻月下人不归 2020-12-10 15:05

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

相关标签:
2条回答
  • 2020-12-10 15:44

    From stdlib.h in the Android source;

    static __inline__ double atof(const char *nptr)
    {
        return (strtod(nptr, NULL));
    }
    

    atof is in other words not a library function, it's an inline function that calls strtod.

    If you need to call through loading a library, just use strtod instead.

    0 讨论(0)
  • 2020-12-10 15:50

    Google have moved some of the C standard library functions like atof() from being inline functions in header files to normal functions. The latest NDKs will default to building a .so that is only compatible with the latest Android devices that have the atof() function in the device's standard C library (libc.so). This means if you run a library on an older device that has an older version of the C library, you will get an error loading the dll as the expected atof() function will not exist.

    Have you tried setting this in your Application.mk:

    APP_PLATFORM := android-9
    

    This will cause the ndk compiler to build code compatible with older Android versions.

    You can also try downgrading your NDK installation to version 10b (this version predates the change where atof was moved from inline to part of libc so avoids the problem entirely).

    0 讨论(0)
提交回复
热议问题