help-gplusplus
[Top][All Lists]
Advanced

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

Re: Multiple Definition of Symbols


From: Ulrich Eckhardt
Subject: Re: Multiple Definition of Symbols
Date: Sat, 19 Nov 2005 13:20:29 +0100
User-agent: KNode/0.9.2

yogesh.kini@gmail.com wrote:
> I am using gcc 4.0  with Xcode 2.2 on Mac OS 10.4.3.
> I am using two static lib's in my project, which in turn include zlib.
> I get "multiple definition of symbol"  Linker error.

No you don't, it also tells you which symbols and where. In C++ you have a
so-called one definition rule (ODR) which seems to be what you have broken
with your program.

> While using msvc 7.0 linker flag "/FORCE:MULTIPLE" eliminates this
> error.

Doing so is the equivalent of performing a brute force C-style cast - the
compiler is completely at the mercy of the programmer, it can't perform
any error checks and if it breaks nothing can be done. I haven't come
across a case where using this flag was a proper fix.0

> Is there a similar flag for gcc?

You could write a linker script or provide some linker flags, but I suggest
fixing the problem and not tampering with the symptoms.

Uli

-- 
http://gcc.gnu.org/faq.html
http://parashift.com/c++-faq-lite/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]