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

I used the following...

~/Development/Android/android-ndk-r8c/build/tools/ --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


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/

/arm-linux-androideabi-gcc test.c

You're missing sysroot in this one.

/arm-linux-androideabi-gcc --sysroot=/sysroot test.c

This one, sysroot is wrong. It ahould be similar to:


You also need to export LD (all the tools should be on path):

$ echo $PATH
$ echo $LD

You should probably export all the tools in the toolchain:

export CPP=arm-linux-androideabi-cpp
export CC=arm-linux-androideabi-gcc
export CXX=arm-linux-androideabi-g++
export LD=arm-linux-androideabi-ld
export AS=arm-linux-androideabi-as
export AR=arm-linux-androideabi-ar
export RANLIB=arm-linux-androideabi-ranlib

If you are working on an Autoconf project, add these:

export CPPFLAGS="--sysroot=$ANDROID_SYSROOT"
export CFLAGS="--sysroot=$ANDROID_SYSROOT"
export CXXFLAGS="--sysroot=$ANDROID_SYSROOT"

Ok looking back I made my toolchain for Android-9 per the command...

~/Development/Android/android-ndk-r8c/build/tools/ --platform=android-9 --install-dir=/tmp/my-toolchain

When I ran...

<install>/android-ndk-r8c$ find ./ -name crtbegin_dynamic*

As you can see my install of android-9 for some reason does not have this file. I rebuilt for android-14 and everything works fine. Anyone have an idea how this got like this? Bonehead file move on my part?

This is what worked for me, I came to this question with the same issue, I am trying to build the gcc-4.8 toolchain in the NDK and ran into the same problem. The thing thats a bit different though about my situation is I am building on an Android device, which means I have the Bionic library and in /system/lib. I was getting this error when configuring for libgomp:

toolchain-build/binutils-2.23/ld/ld-new: cannot find crtbegin_dynamic.o: No such file or directory
toolchain-build/binutils-2.23/ld/ld-new: cannot find -lc
toolchain-build/binutils-2.23/ld/ld-new: cannot find -ldl
toolchain-build/binutils-2.23/ld/ld-new: cannot find crtend_android.o: No such file or directory

The Make file was setting a -B option to a particular directory toolchain/gcc-4.8/gcc/ so I created symlinks from those two shared libs in /system/lib to gcc-4.8/gcc. Then I symlinked crtbegin_dynamic.o and crtend_android.o to the object files crtbegin.o and crtend.o that where compiled and installed into toolchain-build/prefix/lib/gcc/arm-linux-androideabi/4.8/thefind` command can help you find them.

The commands I used to make the symlinks looked like this:

ln -s ../../prefix/lib/gcc/arm-linux-androideabi/4.8/crtend.o crtend_android.o

from within the toolchian-build/gcc-4.8/gcc directory, for me that worked because thats where the configuration was pointing to search with the -B option make passed to xgcc.

I hope that helps someone. Time to move on to libatomic ; )

Need Your Help

What is the alternative for String.format() in GWT?


While GWT is not emulate all java's core, what can be used as alternative for:

Java List <T> T[] toArray(T[] a) implementation

java list generics toarray

I was just looking at the method defined in the List interface: &lt;T&gt; T[] toArray(T[] a)