title: Android Studio CMake - shared library missing libc++_shared.so? Can CMake bundle this?
body: <p>Now that Android Studio 2.2 is released officially, I'm migrating from my old ndk-build process to try and use CMake within AS. As I'm incorporating several codebases from within my company (that I can't edit) that make heavy use of C++11 code (including the dreaded std::to_string() method), the only way I can compile is with a select few configuration options - all of which I discovered earlier when beginning work with ndk-build. (see below)</p>
  
  <p>So everything compiles again and builds into the APK - and I 100% verify that my output shared library exists in the APK, but I'm unable to successfully use <code>System.loadLibrary('mylibrary')</code> - and it turns out this is because the dependency <em>libc++_shared.so</em> is missing. </p>
  
  <p>As in, I get the following error:</p>
  
  <pre><code>java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
  </code></pre>
  
  <p>In my old ndk-build process, I always wound up with the 2 libraries (<em>mylibrary.so</em> and <em>libc++_shared.so</em>) in my output folder, which thereby got bundled together into the app. It seems the CMake toolchain isn't bundling <em>libc++_shared.so at all</em> (indeed, it's not found in the APK). </p>
  
  <p>I've been banging my head on this for 6 hours. Can I somehow get the CMake toolchain to bundle this missing library? Any clues?</p>
  
  <p>.</p>
  
  <p>.</p>
  
  <p><strong>My settings:</strong></p>
  
  <p>In gradle.build:</p>
  
  <pre><code>externalNativeBuild {
          cmake {
              arguments '-DANDROID_STL=c++_shared', '-DANDROID_TOOLCHAIN=gcc', '-DANDROID_PLATFORM=android-16'
          }
      }
  </code></pre>
  
  <p>And my CMakeLists.txt (filenames cut out for brevity):</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.4.1)
  
  set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -std=gnu++11")
  
  include_directories(.)
  include_directories(./other)
  
  set(my_SRCS jniInterface.cpp
      etc.cpp)
  
  
  add_library(mylibrary SHARED ${my_SRCS})
  
  target_link_libraries(mylibrary atomic log)
  </code></pre>