[H-GEN] redefined symbol errors with gcc.

Andrae Muys a.muys at mailbox.uq.edu.au
Wed Nov 10 20:45:04 EST 1999


[ Humbug *General* list - semi-serious discussions about Humbug and
Unix-related topics. ]


Ok, given the following two files and their attempted compilation:

[andrae at reynier test]$ cat multilink1.c 
int main () { }
[andrae at reynier test]$ cat multilink2.c 
int main() { }
[andrae at reynier test]$ gcc -c multilink*.c
[andrae at reynier test]$ gcc -o multilink multilink*.o
multilink2.o: In function `main':
multilink2.o(.text+0x0): multiple definition of `main'
multilink1.o(.text+0x0): first defined here
collect2: ld returned 1 exit status
[andrae at reynier test]$ 

Does anyone know what compile options I can pass to gcc to force this to
succeed?  The simple fact is that this sort of redefinition is used in
various places to provide default implementations of functions in some
libraries.  Yacc is a classic example of this.  Under IRIX I get the
following...

sophe:andrae 12 > cp multitest1.c multitest2.c
sophe:andrae 13 > cc -c multitest*.c
multitest1.c:
multitest2.c:
sophe:andrae 14 > cc -o multitest multitest*.o
ld32: WARNING 15 : Multiply defined:(main) in multitest1.o and
multitest2.o (2nd definition ignored).
sophe:andrae 15 > 

Which is far better.  So does anyone know how I can get gcc to behave?

Andrae

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Andrae Muys              "Never ascribe to malice that which is adequately
andrae at humbug.org.au      explained by incompetence." - Napoleon Bonaparte


--
This is list (humbug) general handled by majordomo at lists.humbug.org.au .
Postings only from subscribed addresses of lists general or general-post.



More information about the General mailing list