Cocos2dx: dlopen failed: cannot locate symbol “atof” referenced by “libcocos2dcpp.so”

I am trying to run my cocos2d-x game on android devices, it works perfectly on android 5.0(lollipop), but crashes on lower android versions. I am getting the following error:

02-27 17:12:45.786: E/art(13118): dlopen("/data/app-lib/com.example.game-1/libcocos2dcpp.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol “atof” referenced by “libcocos2dcpp.so”…
02-27 17:12:45.788: D/AndroidRuntime(13118): Shutting down VM
02-27 17:12:45.801: E/AndroidRuntime(13118): FATAL EXCEPTION: main
02-25 10:41:09.817: D/dalvikvm(18090): Trying to load lib /data/app-lib/com.example.game-2/libcocos2dcpp.so 0x418c9ce8 02-25 10:41:09.817: E/dalvikvm(18090): dlopen("/data/app-lib/com.example.game-2/libcocos2dcpp.so") failed: dlopen failed: cannot locate symbol “atof” referenced by “libcocos2dcpp.so”… 02-25 10:41:09.817: W/dalvikvm(18090): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/example/game/game; 02-25 10:41:09.817: W/dalvikvm(18090): Class init failed in newInstance call (Lcom/example/game/game;) 02-25 10:41:09.817: D/AndroidRuntime(18090): Shutting down VM 02-25 10:41:09.817: W/dalvikvm(18090): threadid=1: thread exiting with uncaught exception (group=0x415af8b0) 02-25 10:41:09.827: E/AndroidRuntime(18090): FATAL EXCEPTION: main 02-25 10:41:09.827: E/AndroidRuntime(18090): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol “atof” referenced by “libcocos2dcpp.so”… 02-25 10:41:09.827: E/AndroidRuntime(18090): at java.lang.Runtime.loadLibrary(Runtime.java:361)example 02-25 10:41:09.827: E/AndroidRuntime(18090): at java.lang.System.loadLibrary(System.java:525) 02-25 10:41:09.827: E/AndroidRuntime(18090): at com.example.game.game.(game.java:126) 02-25 10:41:09.827: E/AndroidRuntime(18090): at java.lang.Class.newInstanceImpl(Native Method) 02-25 10:41:09.827: E/AndroidRuntime(18090): at java.lang.Class.newInstance(Class.java:1130) 02-25 10:41:09.827: E/AndroidRuntime(18090): at android.app.Instrumentation.newActivity(Instrumentation.java:1061) 02-25 10:41:09.827: E/AndroidRuntime(18090): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2178) 02-25 10:41:09.827: E/AndroidRuntime(18090): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2311) 02-25 10:41:09.827: E/AndroidRuntime(18090): at android.app.ActivityThread.access$600(ActivityThread.java:149) 02-25 10:41:09.827: E/AndroidRuntime(18090): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293) 02-25 10:41:09.827: E/AndroidRuntime(18090): at android.os.Handler.dispatchMessage(Handler.java:99) 02-25 10:41:09.827: E/AndroidRuntime(18090): at android.os.Looper.loop(Looper.java:137) 02-25 10:41:09.827: E/AndroidRuntime(18090): at android.app.ActivityThread.main(ActivityThread.java:5214) 02-25 10:41:09.827: E/AndroidRuntime(18090): at java.lang.reflect.Method.invokeNative(Native Method) 02-25 10:41:09.827: E/AndroidRuntime(18090): at java.lang.reflect.Method.invoke(Method.java:525) 02-25 10:41:09.827: E/AndroidRuntime(18090): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) 02-25 10:41:09.827: E/AndroidRuntime(18090): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555) 02-25 10:41:09.827: E/AndroidRuntime(18090): at dalvik.system.NativeStart.main(Native Method).

I am using cocos2d-x v2.2.6,Eclipse-Luna and android NDK r10d.

You should find this stackoverflow question useful.

It is fixed. Now cocos2d-x uses std::atof instead.

@zhangxm I guess you talk about version 3.12 ? no 2.x

@OscarLeif yep, i mean v3.12, sorry for the careless. But you guys can replace atof with std::atof.