title: Clang linking .so library libc++_shared.so
body: <p>I'm having an Error in my Native C++ Code in Android NDK Application</p>
  
  <p>My main.cpp</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() 
  {
    printf("Hello, world\n");
    return 0;
  }
  </code></pre>
  
  <p>The main.c is exactly the same.
  If i run </p>
  
  <pre><code>/home/rip/Music/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang -pie main.c
  </code></pre>
  
  <p>then </p>
  
  <pre><code>adb push a.out /data/local/tmp
  </code></pre>
  
  <p>and </p>
  
  <pre><code>adb shell /data/local/tmp/a.out
  </code></pre>
  
  <p>all works fine. But if i run </p>
  
  <pre><code>/home/rip/Music/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang++ -pie main.cpp
  </code></pre>
  
  <p>then </p>
  
  <pre><code>adb push a.out /data/local/tmp
  </code></pre>
  
  <p>and </p>
  
  <pre><code> adb shell /data/local/tmp/a.out
  </code></pre>
  
  <p>The error message is:</p>
  
  <pre><code>CANNOT LINK EXECUTABLE "/data/local/tmp/a.out": library "libc++_shared.so" not found
  </code></pre>
  
  <p>Then i tried to run</p>
  
  <pre><code>/home/rip/Music/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang++ -pie hello1.cpp  /home/rip/Music/android-ndk-r19b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so
  </code></pre>
  
  <p>to link the library, but it doesn't work anyway.</p>