[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Compile time errors
From: |
Paul Pluzhnikov |
Subject: |
Re: Compile time errors |
Date: |
01 Nov 2004 07:25:58 -0800 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence) |
vineetc@gmail.com (Vineet) writes:
> I am quite puzzled with this seemingly basic issue while compiling.
You do not have an issue while compiling. You have an issue while
*linking*.
> BufMgr.o(.text+0x0): In function `lru::lru[not-in-charge]()':
> : multiple definition of `lru::lru[not-in-charge]()'
> TDD.o(.text+0x0): first defined here
In lru.h, you have code like this:
class lru { lru(); ... };
lru::lru() { ... }
With the code above, every source file that #include's lru.h is
going to *define* 'lru::lru()', resulting in multiple definitions
and a link error.
You have to make 'lru::lru()' inline:
class lru { inline lru(); ... };
or you have to move the definition of 'lru::lru()' out of the header
and into its own lru.cc source file; so it is defined in lru.o and
nowhere else. [Obviously you'll have to add lru.o to your link line].
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.