title: NDK Clang error: undefined reference to 'localeconv'
body: <p>I am trying to build C++ NDK lib inside Android Studio.I have an external lib called <a href="https://github.com/nlohmann/json" rel="noreferrer">json</a> and the Clang compiler faild on localeconv.</p>
  
  <blockquote>
    <p>json.hpp:11867: error: undefined reference to 'localeconv'</p>
  </blockquote>
  
  <p>The locale.h header exists and located inside ndk dir sysroot/usr/include.</p>
  
  <p>My toolchain looks like this:</p>
  
  <p><strong>Gradle:</strong> (Showing only the part relevant to NDK)</p>
  
  <pre><code> externalNativeBuild {
          cmake {
  
              arguments "-DANDROID_PLATFORM_LEVEL=${platformVersion}",
                      '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=gnustl_static'
          }
  
          ndk {
              abiFilters 'armeabi-v7a'
  
          }
      }
  </code></pre>
  
  <p><strong>Cmake</strong></p>
  
  <pre><code> set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11 -Wall")
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -frtti  -fexceptions  -Wall")
  
    //'native-lib' is the final .so that's packaged into apk
         target_link_libraries(native-lib
                     OPENAL
                     FREETYPE
                     android
                      EGL
                      ${OPENGL_LIB}
                      log
                      m
                      z
                      atomic
                      gnustl_static
                      ) 
  </code></pre>
  
  <p><strong>And here is the linker command line:</strong></p>
  
  <blockquote>
    <p>[1/1] Linking CXX shared library
    ........\build\intermediates\cmake\debug\obj\armeabi-v7a\libnative-lib.so
    FAILED: cmd.exe /C "cd . &amp;&amp;
    D:\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe
    --target=armv7-none-linux-androideabi --gcc-toolchain=D:/Android/android-sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64
    --sysroot=D:/Android/android-sdk/ndk-bundle/sysroot -fPIC -isystem D:/Android/android-sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi
    -D__ANDROID_API__=19 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb -Wa,--noexecstack -Wformat -Werror=format-security   -std=c++11 -frtti  -fexceptions  -Wall -O0 -fno-limit-debug-info  -Wl,--exclude-libs,libgcc.a --sysroot D:/Android/android-sdk/ndk-bundle/platforms/android-19/arch-arm
    -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,libnative-lib.so</p>
  </blockquote>
  
  <p><strong>The complete error:</strong></p>
  
  <blockquote>
    <p>"D:/Android/android-sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_static.a"
    &amp;&amp; cd ." D:\XXXXX\XXXXXX\windows....\thirdparty\json/json.hpp:11867:
    <strong>error: undefined reference to 'localeconv'</strong> clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed. :app:externalNativeBuildDebug
    FAILED</p>
  </blockquote>
  
  <p>The target SDK is 21.Minimum SDK is 19.NDK Version: 15.0.4075724</p>
  
  <p>The same code base is compiled fine in Visual Studio Android project which uses the same toolchain.</p>