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


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

Re: link problem (powerpc-elf)


Michael Morrison wrote:
> 
> W Gerald Hicks wrote:
> 
> > Michael Morrison wrote:
> > >
> > > Hi Folks,
> > >
> > > I recently installed GNU cross toolchain for powerpc for both linux and
> > > cygwin hosts.
> > > When I compile/link a simple "hello world" program, I get the following:
> > >
> > > [mike@tux powerpc]$ powerpc-elf-gcc main.c -o main
> > > /opt/powerpc/lib/gcc-lib/powerpc-elf/3.0/../../../../powerpc-elf/bin/ld:
> > > warning: cannot find entry symbol _start; defaulting to 01800074
> > > /tmp/cctRepxT.o: In function `main':
> > > /tmp/cctRepxT.o(.text+0x20): undefined reference to `printf'
> > > collect2: ld returned 1 exit status
> > >
> > > I have: gcc-3.0, binutils-2.11 and newlib 1.9.0
> > >
> > > I also have these tools installed for an arm target and don't have any
> > > problems with it.
> > >
> > > Any clues on where I can begin looking?
> > >
> > > THX
> > > mike
> >
> > Uhm, you need to specify the library in your link step.
> >
> > Cheers,
> >
> > Jerry Hicks
> > gehicks@cisco.com
> 
> Ok,   if I do the following:
> 
> Native linux compiler:   gcc -g hello.c -o hello
> ARM cross compiler    arm-elf-gcc -g hello.c -o hello
> 
> I get resulting 'hello' programs - no additional libraries need to be
> specified; no errors are reported
> If use the powerpc cross tools I get the above errors.
> 
> BTW the arm cross tools and powerpc cross tools are all the same source - just
> configured for different
> targets.   So,  what additional libraries need to be specified on the command
> line for powerpc only?
> 

While they may share some common source, they also have platform-specific code and are not the
same.  The printf routine is in the libc library so you need a -lc specified somewhere.  Whether the
compiler adds -lc for you on the link is part of the compiler design.  You can see what libraries
are being included for you by specifying the -v option while compiling/linking.  You will also need
an OS call layer to support the C library (libgloss).  For powerpc-elf, libgloss builds the files in
the libgloss/rs6000 directory and there are multiple libraries built for you to choose.  If you are
running on the simulator, add -lsim to the end of your compile/link.

-- Jeff J.


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