Skip to content
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

'localeconv' is not supported by NDK for SDK <=20 #638

Closed
sasmaster opened this issue Jun 26, 2017 · 13 comments
Closed

'localeconv' is not supported by NDK for SDK <=20 #638

sasmaster opened this issue Jun 26, 2017 · 13 comments
Labels
platform: android related to Android NDK solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@sasmaster
Copy link

The NDK STL for Android 19 seems to be incomplete.The locale.h is incomplete for sure.It does have a declaration of that method but the std llib probably doesn't,which causes linker error.It would be nice if this lib could support also older Android SDKs.Thanks!

@nlohmann nlohmann added the platform: android related to Android NDK label Jun 26, 2017
@nlohmann
Copy link
Owner

Related: #631

@nlohmann
Copy link
Owner

nlohmann commented Jul 8, 2017

I am confused (I have no experience with NDK).

I am using the following files:

Application.mk

APP_ABI := x86
APP_PLATFORM := android-19
APP_STL := c++_shared
APP_BUILD_SCRIPT := Android.mk

Android.mk

LOCAL_PATH := .
include $(CLEAR_VARS)
LOCAL_MODULE := jsonunit.out
LOCAL_SRC_FILES := ../test/src/unit-algorithms.cpp ../test/src/unit-allocator.cpp ../test/src/unit-capacity.cpp ../test/src/unit-cbor.cpp ../test/src/unit-class_const_iterator.cpp ../test/src/unit-class_iterator.cpp ../test/src/unit-class_lexer.cpp ../test/src/unit-class_parser.cpp ../test/src/unit-comparison.cpp ../test/src/unit-concepts.cpp ../test/src/unit-constructor1.cpp ../test/src/unit-constructor2.cpp ../test/src/unit-convenience.cpp ../test/src/unit-conversions.cpp ../test/src/unit-deserialization.cpp ../test/src/unit-element_access1.cpp ../test/src/unit-element_access2.cpp ../test/src/unit-inspection.cpp ../test/src/unit-iterator_wrapper.cpp ../test/src/unit-iterators1.cpp ../test/src/unit-iterators2.cpp ../test/src/unit-json_patch.cpp ../test/src/unit-json_pointer.cpp ../test/src/unit-meta.cpp ../test/src/unit-modifiers.cpp ../test/src/unit-msgpack.cpp ../test/src/unit-noexcept.cpp ../test/src/unit-pointer_access.cpp ../test/src/unit-readme.cpp ../test/src/unit-reference_access.cpp ../test/src/unit-regression.cpp ../test/src/unit-serialization.cpp ../test/src/unit-testsuites.cpp ../test/src/unit-udt.cpp ../test/src/unit-unicode.cpp ../test/src/unit.cpp
LOCAL_C_INCLUDES += ../src ../test/thirdparty/catch
LOCAL_CPP_FEATURES += exceptions rtti
LOCAL_CPPFLAGS += -fexceptions -frtti -std=c++11
include $(BUILD_EXECUTABLE)

With android-ndk-r15b, I can compile the develop branch without problems:

~/Downloads/android-ndk-r15b/ndk-build NDK_APPLICATION_MK=./Application.mk
[x86] Compile++      : jsonunit.out <= unit-algorithms.cpp
[x86] Compile++      : jsonunit.out <= unit-allocator.cpp
[x86] Compile++      : jsonunit.out <= unit-capacity.cpp
[x86] Compile++      : jsonunit.out <= unit-cbor.cpp
[x86] Compile++      : jsonunit.out <= unit-class_const_iterator.cpp
[x86] Compile++      : jsonunit.out <= unit-class_iterator.cpp
[x86] Compile++      : jsonunit.out <= unit-class_lexer.cpp
[x86] Compile++      : jsonunit.out <= unit-class_parser.cpp
[x86] Compile++      : jsonunit.out <= unit-comparison.cpp
[x86] Compile++      : jsonunit.out <= unit-concepts.cpp
[x86] Compile++      : jsonunit.out <= unit-constructor1.cpp
[x86] Compile++      : jsonunit.out <= unit-constructor2.cpp
[x86] Compile++      : jsonunit.out <= unit-convenience.cpp
[x86] Compile++      : jsonunit.out <= unit-conversions.cpp
[x86] Compile++      : jsonunit.out <= unit-deserialization.cpp
./../test/src/unit-deserialization.cpp:71:15: warning: 'operator<<' is deprecated [-Wdeprecated-declarations]
            j << ss;
              ^
../src/json.hpp:7750:5: note: 'operator<<' has been explicitly marked deprecated here
    JSON_DEPRECATED
    ^
../src/json.hpp:84:44: note: expanded from macro 'JSON_DEPRECATED'
    #define JSON_DEPRECATED __attribute__((deprecated))
                                           ^
./../test/src/unit-deserialization.cpp:119:31: warning: 'operator<<' is deprecated [-Wdeprecated-declarations]
            CHECK_THROWS_AS(j << ss1, json::parse_error&);
                              ^
../src/json.hpp:7750:5: note: 'operator<<' has been explicitly marked deprecated here
    JSON_DEPRECATED
    ^
../src/json.hpp:84:44: note: expanded from macro 'JSON_DEPRECATED'
    #define JSON_DEPRECATED __attribute__((deprecated))
                                           ^
./../test/src/unit-deserialization.cpp:120:33: warning: 'operator<<' is deprecated [-Wdeprecated-declarations]
            CHECK_THROWS_WITH(j << ss2,
                                ^
../src/json.hpp:7750:5: note: 'operator<<' has been explicitly marked deprecated here
    JSON_DEPRECATED
    ^
../src/json.hpp:84:44: note: expanded from macro 'JSON_DEPRECATED'
    #define JSON_DEPRECATED __attribute__((deprecated))
                                           ^
3 warnings generated.
[x86] Compile++      : jsonunit.out <= unit-element_access1.cpp
[x86] Compile++      : jsonunit.out <= unit-element_access2.cpp
[x86] Compile++      : jsonunit.out <= unit-inspection.cpp
[x86] Compile++      : jsonunit.out <= unit-iterator_wrapper.cpp
[x86] Compile++      : jsonunit.out <= unit-iterators1.cpp
[x86] Compile++      : jsonunit.out <= unit-iterators2.cpp
[x86] Compile++      : jsonunit.out <= unit-json_patch.cpp
[x86] Compile++      : jsonunit.out <= unit-json_pointer.cpp
[x86] Compile++      : jsonunit.out <= unit-meta.cpp
[x86] Compile++      : jsonunit.out <= unit-modifiers.cpp
[x86] Compile++      : jsonunit.out <= unit-msgpack.cpp
[x86] Compile++      : jsonunit.out <= unit-noexcept.cpp
[x86] Compile++      : jsonunit.out <= unit-pointer_access.cpp
[x86] Compile++      : jsonunit.out <= unit-readme.cpp
[x86] Compile++      : jsonunit.out <= unit-reference_access.cpp
[x86] Compile++      : jsonunit.out <= unit-regression.cpp
[x86] Compile++      : jsonunit.out <= unit-serialization.cpp
./../test/src/unit-serialization.cpp:71:15: warning: 'operator>>' is deprecated [-Wdeprecated-declarations]
            j >> ss;
              ^
../src/json.hpp:7443:5: note: 'operator>>' has been explicitly marked deprecated here
    JSON_DEPRECATED
    ^
../src/json.hpp:84:44: note: expanded from macro 'JSON_DEPRECATED'
    #define JSON_DEPRECATED __attribute__((deprecated))
                                           ^
./../test/src/unit-serialization.cpp:80:15: warning: 'operator>>' is deprecated [-Wdeprecated-declarations]
            j >> ss;
              ^
../src/json.hpp:7443:5: note: 'operator>>' has been explicitly marked deprecated here
    JSON_DEPRECATED
    ^
../src/json.hpp:84:44: note: expanded from macro 'JSON_DEPRECATED'
    #define JSON_DEPRECATED __attribute__((deprecated))
                                           ^
./../test/src/unit-serialization.cpp:91:15: warning: 'operator>>' is deprecated [-Wdeprecated-declarations]
            j >> ss;
              ^
../src/json.hpp:7443:5: note: 'operator>>' has been explicitly marked deprecated here
    JSON_DEPRECATED
    ^
../src/json.hpp:84:44: note: expanded from macro 'JSON_DEPRECATED'
    #define JSON_DEPRECATED __attribute__((deprecated))
                                           ^
3 warnings generated.
[x86] Compile++      : jsonunit.out <= unit-testsuites.cpp
[x86] Compile++      : jsonunit.out <= unit-udt.cpp
[x86] Compile++      : jsonunit.out <= unit-unicode.cpp
[x86] Compile++      : jsonunit.out <= unit.cpp
[x86] Prebuilt       : libc++_shared.so <= <NDK>/sources/cxx-stl/llvm-libc++/libs/x86/
[x86] Executable     : jsonunit.out
[x86] Install        : jsonunit.out => libs/x86/jsonunit.out
[x86] Install        : libc++_shared.so => libs/x86/libc++_shared.so

(ignore the deprecation warnings).

What can I do to reproduce this issue?

@CodeMasterYi
Copy link

Instead of goolge's android ndk, using CrystaX NDK 10.3.x maybe ok!

@CodeMasterYi
Copy link

It would be nice if this lib could support also older Android SDKs

By the way, this issue is nothing about Android SDK but Android NDK.

@nlohmann
Copy link
Owner

So with which version can I reproduce the issue?

@CodeMasterYi
Copy link

what i have tried is:
r10e
and with

APP_STL := c++_shared
APP_PLATFORM := android-11
NDK_TOOLCHAIN_VERSION=4.9

maybe, "android-19" is also the same~
i have no time to try it now, you can try it now~

@nlohmann
Copy link
Owner

And that was with the official NDK?

@CodeMasterYi
Copy link

CodeMasterYi commented Jul 10, 2017

yes, official!
Google Android NDK does not fully implement stl and something else, but crystax ndk 10.+ does!

I am not aware of the features of the latest version of Google Android NDK!

@sasmaster
Copy link
Author

Guys,if you use Android Studio,the fix to this issue is to use Clang toolchain and STL = C++_static.
Here is the line from my gradle:
'-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=c++_static'

In this case there is no need to refactor anything in the lib. Clang's STL fully supports locale.h

@CodeMasterYi
Copy link

how about c++_share?

@sasmaster
Copy link
Author

sasmaster commented Jul 10, 2017 via email

@nlohmann
Copy link
Owner

@sasmaster Does this mean this issue can be closed?

@sasmaster
Copy link
Author

sasmaster commented Jul 11, 2017 via email

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Jul 11, 2017
headupinclouds added a commit to hunter-packages/json that referenced this issue Aug 9, 2017
SFINAE workaround for missing lconv support in Android (gcc + libstdc++)
See: fmtlib/fmt@2fd6c0b

Discussion: nlohmann#638 (comment)
Note: Clang + libc++ should work (where available)

Returns the thousands separator for the current locale.
On android (gcc/libstdc++) the lconv structure is stubbed using an empty structure
The test is for the size only, not for the presense of
thousands_sep in std::lconv, because if one would add thousands_sep
at some point, the size of structure would be at least sizeof(char*)

Ditto for decimal_point.
headupinclouds added a commit to hunter-packages/json that referenced this issue Aug 9, 2017
SFINAE workaround for missing lconv support in Android (gcc + libstdc++)
See: fmtlib/fmt@2fd6c0b

Discussion: nlohmann#638 (comment)
Note: Clang + libc++ should work (where available)

Returns the thousands separator for the current locale.  On android (gcc/libstdc++) the lconv structure is stubbed using an empty structure.  The test is for the size only, not for the presense of thousands_sep in std::lconv, because if one would add thousands_sep at some point, the size of structure would be at least sizeof(char*)

Ditto for decimal_point.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: android related to Android NDK solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

3 participants