This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

undefined references calling libc functions


Hello.

I setup a crosscompiler on intel platform using win2k for powerpc target.
Therefor i installed cygwin.
Setup of binutils, gcc-2.95.2-6 and newlib-1.9.0 was successful.

-------------------------------------------------------------------------------------------------------------------------
I wanted to test my CrossGcc with a simple hello program, but the linker
failed
resolving the libc library call to printf. It also failed with other libc
calls.
The libc.a is available within the directory i passed to gcc.

$ $target-gcc -e main -mno-eabi
-I$src_root/BUILD/newlib/powerpc-eabi/newlib/usr/local/powerpc/powerpc-eabi/include 
-L$prefix/lib -lc -o hello hello.c
cygdrive/c/DOKUME~1/ADMINI~1/LOKALE~1/Temp/cc5h1NDo.o: In function `main':
cygdrive/c/DOKUME~1/ADMINI~1/LOKALE~1/Temp/cc5h1NDo.o(.text+0x20):
undefined reference to `printf'
collect2: ld returned 1 exit status
--------------------------------------------------------------------------------------------------------------------------

I did the following to create the parts of the crosscompiler.

Step 1:
$ host=i686-pc-cygwin
$ build=i686-pc-cygwin
$ target=powerpc-eabi
$ prefix=/usr/local/powerpc
$ src_root=/usr/local/src/gnu
-------------------------------------------------------------------------------------------------------------------------
Step 2:
unpack the packages for binutils, gcc and newlib
-------------------------------------------------------------------------------------------------------------------------
Step 3: build and install binutils

$ mkdir -p $src_root/BUILD/binutils
$ cd $src_root/BUILD/binutils
$ $src_root/binutils-2.10.1/configure \
    --with-included-gettext \
    --target=$target --host=$host --build=$build \
    --prefix=$prefix -v

$ make > make.log 2>&1
$ make install > install.log 2>&1
------------------------------------------------------------------------------------------------------------------------
Step 4:   build and install the gnu c-compiler

$ mkdir -p $src_root/BUILD/gcc
$ cd $src_root/BUILD/gcc
$ $src_root/gcc-2.95.2/configure \
    --enable-languages=c,c++ \
    --with-included-gettext --enable-shared --enable-threads \
    --target=$target --host=$host --build=$build \
    --with-gnu-as --with-gnu-ld --with-newlib \
    --prefix=$prefix -v

$ make LANGUAGES=c all-gcc > make.log 2>&1
$ make LANGUAGES=c install-gcc > install.log 2>&1
--------------------------------------------------------------------------------
---------------------------------------
Step 5: build and install the newlib

$ mkdir -p $src_root/BUILD/newlib
$ cd $src_root/BUILD/newlib
$ $src_root/newlib-1.9.0/configure \
    --target=$target --host=$host --build=$build \
    --prefix=$prefix -v

$ make > make.log 2>&1
$ make install > install.log 2>&1
----------------------------------------------------------------------------------------------------------------------
Step 6: build and install rest of the gcc compiler (language, runtime and
support libraries)
$ cd $src_root/BUILD/gcc
$ make > make.log 2>&1
$ make install > install.log 2>&1
----------------------------------------------------------------------------------------------------------------------
Step 7: Wrote a simple hello program like below and
     started crying because of linker failure.

#include <stdio.h>

int main()
{
  printf("hello");
  return 0;
}
----------------------------------------------------------------------------------------------------------------------

It seems that something failed creating the newlib for powerpc target, but
in
the log-files make.log and install.log i can't find any errors.
The gcc components seems to be ok, because i tested a short example program
without libc library calls on the target system.

Is there an error within the steps i did ?
I took a closer look to the gcc manual, but i can't find any additional
arguments i should pass
to gcc.
I think i don't need a startup file like crt0.o, because i build for a
target without a system.

I hope someone can help me.

Regards Mathias



------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]