Re: gcc linker help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kanak Nath wrote:

> I've created a small .c code and it has calls to strlen() and printf(). I compiled it with arm-elf-gcc  -mcpu=arm9  -c \example\test.c to generate test.o. Now I wanted to link it with arm-elf-ld test.o c:\gnude\lib\gcc-lib\arm-elf\3.3.1\libgcc.a. I get the following error:
> 
> : undefined reference to `strlen'
> test.o(.text+0x50): In function `main':
> : undefined reference to `printf'

Functions like strlen and printf come from the C library (such as glibc,
newlib, uclibc, etc.)  Libgcc is something completely different, and it
only provides a small number of support routines that are used
internally by the compiler, not functions that you'd call in normal
code.  You need to link against whatever C library your toolchain uses.

Most of the time, it is a bad idea to link by calling ld directly.  The
gcc front-end program itself is designed to do this, so you should
always link with "gcc -o filename object1.o object2.o" unless you know
exactly what you're doing.  The front-end will add all the necessary
auxillery object files, library files, and linker switches which are
necessary - there can be a lot of these.

Finally, you appear to be using some specific toolchain from some vendor
(whatever "gnude" is), and so if you can't get it working you really
need to contact them.  The gcc project does not have anything to do with
these specific toolchain bundles, only the "vanilla" gcc - and even if
it did you'd have a hard time trying to get help with an ancient version
like 3.3.1.

Brian

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux