Crtbegin_so.o is missing for binding android toolchain (custom build)

I compiled gdc with gcc using the android build-gcc.sh script and included a new stub in build / core / definitions.mk to handle D language files as part of the build process. I know that at this moment everything compiles, but my problem is related to:

When I create a project, I get this error:

ld: crtbegin_so.o: No such file: No such file or directory 

This is true for regular c-only projects. Now I quickly found the build directory in my directory and found that the file (crtbegin_so.o) exists in sysroot, which I specified when compiling gcc (or, rather, when build-gcc.sh built it).

  • What can I find to find a solution to this problem?

  • Copying files locally and linking them directly to them will be a worthy solution in a temporary one?

  • Why is ld (or collect2) trying to include them for the gdc (D Language) link?

+6
source share
4 answers

The problem also arises for NDK r7c for linux.

I found that the tool chain ignores the location of the platform ($ NDK_ROOT / platform / android-8 / arch-arm / usr / lib /) and looks for it in the tool chain path, which is incorrect.

However, since toolchain is also looking for a file in the current directory, one solution is to symlink the correct platform crtbegin_so.o and crtend_so.o to the source directory:

cd src && ln -s NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtbegin_so.a

cd src && ln -s NDK_ROOT/platforms/android-8/arch-arm/usr/lib/crtend_so.a

So your second paragraph should work (where you can make a symbolic link instead of a copy)

NOTE 1: It is assumed that the code is compiled for API8 (Android 2.2) using the NDK. Please change the path to the correct path as per your requirement.

NOTE 2: Configuring the flags used:

 ./configure \ --host=arm-linux-androideabi \ CC=arm-linux-androideabi-gcc \ CPPFLAGS="-I$NDK_ROOT/platforms/android-8/arch-arm/usr/include/" \ CFLAGS="-nostdlib" \ LDFLAGS="-Wl,-rpath-link=$NDK_ROOT/platforms/android-8/arch-arm/usr/lib/ -L$NDK_ROOT/platforms/android-8/arch-arm/usr/lib/" \ LIBS="-lc" 
+10
source

I found that adding --sysroot=$(SYSROOT) to the compiler options fixes the error:

cannot open crtbegin_so.o: no such file or directory

from my makefile ...

 CC= $(CROSS_COMPILE)gcc -fvisibility-hidded $(INC) $(LIB) -shared 

Note. It is assumed that setenv-android.sh is running to set up the $. ./setenv-android.sh environment $. ./setenv-android.sh $. ./setenv-android.sh

+2
source

In my case, the quotes were missing on the sysroot path. When i changed

 --sysroot=${ANDROID_NDK}\platforms\android-17\arch-arm 

to

 --sysroot="${ANDROID_NDK}\platforms\android-17\arch-arm" 

The project has been compiled and successfully linked.

+1
source

I encountered the same problem in two separate cases:

Once I switched to the standalone toolchain problem, here is an example of a command that prepares the standalone toolchain

 $NDK_ROOT/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=android-toolchain --ndk-dir=$NDK_ROOT --system=darwin-x86_64 --toolchain=arm-linux-androideabi-4.9 

Raise specific

to increase you need to specify --sysroot several times in jam

 <compileflags>--sysroot=$NDK_ROOT/platforms/android-9/arch-arm <linkflags>--sysroot=$NDK_ROOT/platforms/android-9/arch-arm 
0
source

Source: https://habr.com/ru/post/893922/


All Articles