This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


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

Re: Undefined Reference


"Eddie CHEUNG [ESD]" wrote:
> 
> I just built a cross complier hosted on solaris target to powerpc-elf.
> 
> When I test the cross gcc with my hello.c
> 
> #include <stdio.h>
> int main()
> {
>  printf("Hello World\n");
>  return 0;
> }
> 
> Errors come up:
> 
> /opt/crossgcc/powerpc-elf/bin/gcc hello.c -o hello.o
> /opt/crossgcc/powerpc-elf/bin/ld: warning: cannot find entry symbol _start; defaulting to 01800074
> /var/tmp/ccWKCEit.o: In function `main':
> /var/tmp/ccWKCEit.o(.text+0x20): undefined reference to `printf'
> collect2: ld returned 1 exit status
> make: *** [hello.o] Error 1
> 
> It seems to be the linker can not link the standard library. Can anyone help?

GCC does not include libc in the link by default.  You must explicitly
include it:

   gcc hello.c -o hello -L/path/to/libc.a -lc

As for _start, sounds like powerpc-elf may not include a default crt0.o?

------
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]