Search code examples
android-ndk

Android: error: cannot open crtbegin_dynamic.o: No such file or directory


I used the following...

~/Development/Android/android-ndk-r8c/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=/Users/me/toolchain

Then I create the following code file...

int main ()
{
  return 0;
}

I tried ...

<toolchain>/arm-linux-androideabi-gcc test.c

I also tried

 <toolchain>/arm-linux-androideabi-gcc --sysroot=<toolchain>/sysroot test.c 

Both come back...

 toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtbegin_dynamic.o: No such file or directory

Solution

  • To make it simpler, just set the sysroot:

    <toolchain>/arm-linux-androideabi-g++ ~/test.c -o ~/test --sysroot=/home/user/android-ndk/platforms/android-9/arch-arm/