public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* ld: cannot find -lc (Building gcc for Android toolchain)
@ 2011-10-17 10:42 Alexey Umnov
  2011-10-17 11:21 ` Kai Ruottu
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Umnov @ 2011-10-17 10:42 UTC (permalink / raw)
  To: gcc-help

Hello!
Over the last few days I cannot succeed building an android toolchain.

Initial data:
Ubuntu 11.10 (11.04 also tried)
gcc 4.6.1
binutils-2.21.1
glibc-2.14 with glibc-ports-2.13, linuxthreads and linuxthreads_db plugins

TARGET=arm-linux-androideabi
PREFIX=/opt/android-9-toolchain/ndk/ #(not original ndk)
SYSROOT=/opt/android-9-toolchain/sysroot

SYSROOT has three symlinks to android ndk includes:
$SYSROOT/usr/include/asm -> $NDK/platforms/android-9/arch-arm/usr/include/asm
$SYSROOT/usr/include/asm-generic ->
$NDK/platforms/android-9/arch-arm/usr/include/asm-generic/
$SYSROOT/usr/include/linux ->
$NDK/platforms/android-9/arch-arm/usr/include/linux/
So, it seems like all requirements are satisfied...

Ok.

As far as I know the usual strategy of building toolchain is following:
1. build binutils
2. build 1st gcc
3. build libc by means of 1st gcc
4. build final gcc by means of 1st gcc

Binutils has been configured as follows:
../configure --prefix=$PREFIX --target=$TARGET
, built fine and installed to $PREFIX

But I encountered a problem building 1st gcc. It has been configured as follows:
../configure --prefix=$PREFIX --target=$TARGET --enable-languages=c
--disable-threads
Also, "-Dinhibit_libc -D__gthr_posix_h" has been appended to the
variable TARGET_LIBGCC2_CFLAGS located in
GCC_DIR/gcc/config/arm/t-linux-androideabi. I read it would inhibit
all libc-related code during compilation...

And it ends up with following:
[............]
 the static library.  */"; echo "GROUP ( libgcc_s.so.1 libgcc.a )" ) >
armv7-a/libgcc_s.so
/opt/android-9-toolchain/ndk/arm-linux-androideabi/bin/ld: cannot find -lc
collect2: ld returned 1 exit status
make[4]: *** [libgcc_s.so] Error 1
[............]

As I understand the compilation (at least of some part) has been
succeeded, but linkage failed. Strange that linker tries to link
something with libc. There mustn't be any libc-code because of
"inhibit_libc" hack...

Have I missed something?

ANY helpful links related to building android (or even any arm)
toolchain are welcome as well.

Thank you in advance!
______________________
Alexey Umnov
umnoff@gmail.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ld: cannot find -lc (Building gcc for Android toolchain)
  2011-10-17 10:42 ld: cannot find -lc (Building gcc for Android toolchain) Alexey Umnov
@ 2011-10-17 11:21 ` Kai Ruottu
  0 siblings, 0 replies; 2+ messages in thread
From: Kai Ruottu @ 2011-10-17 11:21 UTC (permalink / raw)
  To: gcc-help

17.10.2011 13:41, Alexey Umnov kirjoitti:

> Over the last few days I cannot succeed building an android toolchain.
>
> As far as I know the usual strategy of building toolchain is following:
> 1. build binutils
> 2. build 1st gcc
> 3. build libc by means of 1st gcc
> 4. build final gcc by means of 1st gcc

Not at all!

The usual strategy with already existing targets like with an installed
Android is :

1. build binutils using '--with-sysroot=$sysroot' in configure
2. copy/install/unpack the target's own C library into the chosen
    $sysroot
3. build GCC using '--with-sysroot=$sysroot' in configure

If the target's standard C library already exists, there is no sanity
in trying to replace it with something self-made. With the traditional
proprietary/custom targets like the Unices (Solaris, Ultrix, AIX, HP-UX,
Irix,...) there were no sources for their C libraries and the custom
Linux distros like Red Hat, SuSE, Debian always had their own patched
glibc...

Android is AFAIK quite a "custom" Linux and has its own patched C
library, patched GUI libraries etc. Just use them with your own
crosstoolchain, building only binutils and GCC for your cross-host!

>
> Binutils has been configured as follows:
> ../configure --prefix=$PREFIX --target=$TARGET
> , built fine and installed to $PREFIX

The '--with-sysroot=$sysroot' to point to the target C libraries was
forgotten!

Please check that in this maillist is just now another thread for
just your problem!  What I wrote, was "how things should succeed"
but the Android case seems to be harder, like giving :

configure: error: No support for this host/target combination.
make[1]: *** [configure-target-libstdc++-v3] Erreur 1

during the libstdc++-v3 configure for the target in gcc-4.6.1
sources :(

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-17 11:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-17 10:42 ld: cannot find -lc (Building gcc for Android toolchain) Alexey Umnov
2011-10-17 11:21 ` Kai Ruottu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).