libstdc++ and libc 5
H.J. Lu
hjl@lucon.org
Wed Jul 29 23:12:00 GMT 1998
>
> Here is an example without underscores for your enjoyment.
>
> % g++ -static foo2.cc
> /usr/lib/libc.a(putc.o): In function `_IO_putc':
> putc.o(.text+0x0): multiple definition of `_IO_putc'
> /usr/lib/libstdc++.a(ioputc.o):/f/local/src/libstdc++-2.8.1.1/libraries/libio/ioputc.c:28: first defined here
> /usr/i586-pc-linux-gnulibc1/bin/ld: Warning: size of symbol `_IO_putc' changed from 51 to 50 in putc.o
>
> % cat foo2.cc
> #include <iostream.h>
> #include <streambuf.h>
>
> istream x;
> extern "C" int putc(), fgets();
>
> main () {
> x.get();
> putc();
> fgets();
> x.gets(0, 0);
> }
>
>
I can see the problem now. libio in egcs includes
iogetc.o ioputc.o iofeof.o ioferror.o filedoalloc.o
fileops.o genops.o iofclose.o iovsprintf.o iovsscanf.o
strops.o iogetline.o
in libstdc++ for libc 5. But they don't define the same
symboles as the one in libc 5. Take ioputc.o for example,
it defines _IO_putc and it will define putc only if
weak_alias is defined. For libc 5, putc is not defined
in ioputc.o. That leads the link problem on libc 5.
We have to make sure
iogetc.o ioputc.o iofeof.o ioferror.o filedoalloc.o
fileops.o genops.o iofclose.o iovsprintf.o iovsscanf.o
strops.o iogetline.o
define everything libc 5 defines. We can use something like
#pragma weak putc = _IO_putc
I can provide a patch if necessary.
--
H.J. Lu (hjl@gnu.org)
More information about the Gcc
mailing list