linking issues w/NDK

1,898 views
Skip to first unread message

Gerry Reno

unread,
Apr 18, 2012, 2:58:29 PM4/18/12
to android-ndk
We have built an internal setup for building existing C projects w/std Makefiles using NDK.

With android-ndk-r6 this builds libraries just fine.

The only issue we see with r6 is when it tries to build executables and then we see these errors:
using android-ndk-r6:

arm-linux-androideabi/bin/ld: warning: cannot find entry symbol _start; defaulting to 00008518

So does Android NDK not have crt0.o? Do we need to compile our own crt0.o and link it in for executables?


---------------------------------------------------------------------------------
With android-ndk-r7c we see this error even trying to link libraries:

arm-linux-androideabi/bin/ld: crtbegin_so.o: No such file: No such file or directory

Here the relevant linking setup:

LDFLAGS="-nostdlib
-Wl,-rpath-link=/usr/local/android-ndk/platforms/android-9/arch-arm/usr/lib/,-rpath-link=/home/greno/build/Android/2.3/PROJECT/libs/armeabi/,-dynamic-linker=/system/bin/linker
-L/usr/local/android-ndk/platforms/android-9/arch-arm/usr/lib/
-L/home/greno/build/Android/2.3/PROJECT/libs/armeabi/" LIBS="-lc"

# ls -ld /usr/local/android-ndk/platforms/android-9/arch-arm/usr/lib/crtbegin_so.o
-rwxrwxrwx 1 root root 1068 Aug 3 2011 /usr/local/android-ndk/platforms/android-9/arch-arm/usr/lib/crtbegin_so.o

The android system lib path is both in rpath-link and in -L so why is android-ndk-r7c having a problem finding
crtbegin_so.o?


David Turner

unread,
Apr 18, 2012, 3:00:43 PM4/18/12
to andro...@googlegroups.com
Try using --sysroot=$NDK/platforms/android-9/arch-arm instead





--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Gerry Reno

unread,
Apr 18, 2012, 3:16:08 PM4/18/12
to andro...@googlegroups.com
Ok, tried sysroot but looks like we need to reengineer the setup to be able to use it:

configure: error: unrecognized option: `--sysroot=/usr/local/android-ndk/platforms/android-9/arch-arm'

I'll play around with this and see if I can get it to work in our setup.

On 04/18/2012 03:00 PM, David Turner wrote:
> Try using --sysroot=$NDK/platforms/android-9/arch-arm instead
>

> On Wed, Apr 18, 2012 at 8:58 PM, Gerry Reno <gr...@verizon.net <mailto:gr...@verizon.net>> wrote:
>
> We have built an internal setup for building existing C projects w/std Makefiles using NDK.
>
> With android-ndk-r6 this builds libraries just fine.
>
> The only issue we see with r6 is when it tries to build executables and then we see these errors:
> using android-ndk-r6:
>
> arm-linux-androideabi/bin/ld: warning: cannot find entry symbol _start; defaulting to 00008518
>
> So does Android NDK not have crt0.o? Do we need to compile our own crt0.o and link it in for executables?
>
>
> ---------------------------------------------------------------------------------
> With android-ndk-r7c we see this error even trying to link libraries:
>
> arm-linux-androideabi/bin/ld: crtbegin_so.o: No such file: No such file or directory
>
> Here the relevant linking setup:
>
> LDFLAGS="-nostdlib
>
> -Wl,-rpath-link=/usr/local/android-ndk/platforms/android-9/arch-arm/usr/lib/,-rpath-link=/home/greno/build/Android/2.3/PROJECT/libs/armeabi/,-dynamic-linker=/system/bin/linker
> -L/usr/local/android-ndk/platforms/android-9/arch-arm/usr/lib/
> -L/home/greno/build/Android/2.3/PROJECT/libs/armeabi/" LIBS="-lc"
>
> # ls -ld /usr/local/android-ndk/platforms/android-9/arch-arm/usr/lib/crtbegin_so.o
> -rwxrwxrwx 1 root root 1068 Aug 3 2011 /usr/local/android-ndk/platforms/android-9/arch-arm/usr/lib/crtbegin_so.o
>
> The android system lib path is both in rpath-link and in -L so why is android-ndk-r7c having a problem finding
> crtbegin_so.o?
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.

> To post to this group, send email to andro...@googlegroups.com <mailto:andro...@googlegroups.com>.


> To unsubscribe from this group, send email to android-ndk...@googlegroups.com

> <mailto:android-ndk%2Bunsu...@googlegroups.com>.

Gerry Reno

unread,
Apr 18, 2012, 3:28:54 PM4/18/12
to andro...@googlegroups.com
For the configure step I changed it to --with-sysroot and then configure ran but errored out:

./configure CC=arm-linux-androideabi-gcc
PATH=$PATH:/usr/local/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin
--with-sysroot=/usr/local/android-ndk/platforms/android-9/arch-arm
...
configure:3251: checking whether the C compiler works
configure:3273: arm-linux-androideabi-gcc conftest.c >&5
/usr/local/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld:
crtbegin_dynamic.o: No such file: No such file or directory
collect2: ld returned 1 exit status

David Turner

unread,
Apr 18, 2012, 4:51:56 PM4/18/12
to andro...@googlegroups.com
Ah, the --sysroot option must be part of your CC, but some configure scripts will bark at this because they don't handle a CC value that is made of several  space-separated options.

Really, the best thing to do is to use make-standalone-toolchain.sh instead of trying to use the binaries directly from $NDK/toolchains/arm-linux-androideabi-4.4.3/.../
Reply all
Reply to author
Forward
0 new messages