title: How do I fix "ld: error: unable to find library -lgcc" when cross-compiling rust to android?
body: <p>I'm trying to get rust working on android. However, when I try to cross-compile to android I get the following linking error:</p>
  <pre><code>$ cargo build --target=arm-linux-androideabi
     Compiling &lt;project&gt; v0.1.0 (&lt;project&gt;)
  error: linking with `/opt/android-sdk/ndk/23.0.7599858/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi31-clang` failed: exit status: 1
  
  (very long toolchain command from cargo)
  
  ld: error: unable to find library -lgcc
            clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  <p>I have installed the ndk and changed the linker in <code>.cargo/config</code> to the android clang linker. I also tried the standalone toolchains with the same result. The guide I used was the following: <a href="https://mozilla.github.io/firefox-browser-architecture/experiments/2017-09-21-rust-on-android.html" rel="noreferrer">https://mozilla.github.io/firefox-browser-architecture/experiments/2017-09-21-rust-on-android.html</a></p>
  <p>Cross-compilation does work when using <code>crate-type = [&quot;rlib&quot;]</code> instead of <code>crate-type = [&quot;cdylib&quot;]</code>, but I need an <code>.so</code> file not an <code>.rlib</code> file.</p>
  <p>In case it's relevant, i'm using Manjaro Linux.</p>