-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error compile Android NDK error: 'strtof' is not a member of 'std' #219
Comments
For ERANGE see the PR. However, the std::strtof in the latest NDK STL looks fine to me and seems to be correctly used in this project. So I would say that there is a problem in your project setup (outdated NDK, weird defines, wrong STL?) and you rather find a solution in an Android developer forum :). Also try to only run the preprocessor on the problematic source code and check if the included headers are actually defining strtof and are |
I came across the same problem (in my project, changing or tweaking NDK settings was not an option because of other dependancies) and ended up fixing using a workaround. I hope there would be a cleaner solution though.. What I did: For GCC 4.9 (for example ndk r10d): Add to_string in the beginning of json.hpp
Use strtod in two places (warning! this will of course lose precision and maybe other errors):
For GCC 4.8 this was also needed (ndk r9c):
|
Hi, @nlohmann , I tested the commit PR #222, when I am compiling in Android NDK, this error was solved: I am using the Android NDK configuration, and doesn't support those function c. Application.MK:
this commit of the repository #c0bb5a5 work fine for my Android project |
I use CrystaX NDK and it compiles all fine for android. |
Instead of Google NDK I use CrystaX NDK (latest 10.3.1 from https://www.crystax.net). |
How about the GCC 4.9, I posted two workarounds for that too? Its just a bit uncomfortable that a great lib is not compatible with some common dev envs because of such a small changes.. Or am I missing some bigger issues here? Is it so that it's not recommended to use the lib with changes that I made? (I am not super familiar with c++11 "specialities") |
@vjjjv Can you not use the c++-shared standard library to get the missing to_string function? |
I am not sure, because I experience this problem using Unity and Qt frameworks for example - there the NDK settings come predefined and its not very clear if I can change them easily. |
Can someone please provide an example project so I can try to execute the build myself? (I have no experience with Android NDK - I just want to install it in an Ubuntu VM and try it myself.) |
Ok, I tried the following: I got Android NDK, Revision 11c and compiled the unit tests with the following files in a subdirectory
Executing I have no experience with Android NDK. Can someone please tell me:
I really want to experience the reported problems on my machine to assess whether it makes sense to adjust the code. This may also be applicable to #136. |
I had another try with the configuration above and only adjusted the
|
I forgot to mention: So far, I was not able to reproduce the |
I checked another NDK:
|
Thank you for investigating this! Can you try with this Application.mk: APP_ABI := x86 For me, this is how the issue re-produces. With "APP_STL := c++_shared" there is no issues, but as I mentioned before, in our project we cannot change the STL version. |
Ok, I'll check this weekend. Which NDK version and compiler shall I try? |
For us, r10d GCC 4.9 is relevant |
I can reproduce the error. Combinations that do not work:
Combinations that do work:
A longer explanation can be found here. Is changing to one of the working combinations an option for you @vjjjv? |
(I removed the bug label, because the error is out of scope of the library, but is a known issue for the combination of used options in Android NDK) |
Interesting results on this one after all. We are using this json-lib in component that has to work with Unity and Qt frameworks - so it might be quite challenging to change the NDK options. But I could think Unity and Qt are also moving towards these better working setups in the long run. For now we are quite happy with the workarounds I have posted here earlier. It seems that this should not be fixed in the json lib now when we know where the problem originates from. |
I added a note to the README file and linked this discussion. |
Does anyone have this working for the most recent NDK while using gradle? I use
and I still get the 'to_string' is not a member of 'std' |
I could compile the code, see #451 (comment). |
I have no idea why but I needed this instead (this took me a few hours to figure out so hopefully it helps someone on Android using Gradle...):
|
@haydenkaizeta Thanks for sharing. Could you please give the exact version numbers so I can add a hint to the README? |
android-ndk-r13b, buildToolsVersion "24.0.3", ANDROID_STL=c++_shared, built with clang |
For me compiles ok with CrystaX NDK (but I'm not using this lib as separate cmake module, just include as header) |
When using gnustl, add More detail:
see: https://stackoverflow.com/a/34352742/2395134 for armeabi-v7a , need |
hi, can you help me, this error occurs when it compile with Android NDK
The text was updated successfully, but these errors were encountered: