help-gplusplus
[Top][All Lists]
Advanced

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

Re: How to suppress the "multiple definitions of symbol"


From: csmgroup
Subject: Re: How to suppress the "multiple definitions of symbol"
Date: 4 Dec 2006 18:01:40 -0800
User-agent: G2/1.0

> No, the lack of inline caused it.
Hmm, I wanted to say that I found out the error is caused by 'not using
inline'. I missed that part and it works well for the small code.

The real problem is that even after I  declared the class functions as
inline, and even after forcing it to alwasy be a inline function, it
doesn't look like it becomes a inline function under the Mac OS X.

template<class T>
inline void __attribute__((always_inline))
SPtr<T>::createInstance(const char  *classID,
                        IBase       *reserved)
{

This is an error message.

ld: multiple definitions of symbol
__ZN8oaCommon4SPtrIN12OpenAccess_46IPcellEE14createInstanceEPKcPNS_5IBaseE
../../lib/wafer/mac_osx_32/opt/oaDesignInst.pic.o definition of
__ZN8oaCommon4SPtrIN12OpenAccess_46IPcellEE14createInstanceEPKcPNS_5IBaseE
in section (__TEXT,__text)
../../lib/wafer/mac_osx_32/opt/oaFrame.pic.o definition of
__ZN8oaCommon4SPtrIN12OpenAccess_46IPcellEE14createInstanceEPKcPNS_5IBaseE
in section (__TEXT,__text)

And this is the result for 'nm oaDesignInst.o'. oaDesignInst.o includes
the SPtr class.

         U oaCommon::oaPlugInMgr::getPlugInMgr()
         U oaCommon::oaPlugInMgr::createInstance(char const*,
oaCommon::IBase*, oaCommon::Guid const&, void**)
         U oaCommon::oaPlugInMgr::getClassFactory(char const*,
oaCommon::Guid const&, void**)
00002128 T oaCommon::SPtr<OpenAccess_4::IPcell>::createInstance(char
const*, oaCommon::IBase*)
00026848 S
__ZN8oaCommon4SPtrIN12OpenAccess_46IPcellEE14createInstanceEPKcPNS_5IBaseE.eh

Out of the two result, I see that the function is not inlined.
I think I can solve this problem by changing all the header files. But
if I can force the inline functions to be inline or just suppressing
the errors, I prefer that.


Ulrich Eckhardt wrote:
> csmgroup@gmail.com wrote:
> > Yes, the inline was the cause of the problem.
>
> No, the lack of inline caused it.
>
> >> There might be a flag to suppress such errors, but why not write
> >> correct code instead?
> >
> > Actually, I'm compiling OpenAccess open source (CAD tool) under Mac OS
> > X and Linux.
> > With Mac OS X, there is a case the inline code just becomes function
> > which casues the duplication error.
>
> Please reread what Paul said, the problem was that code was written to be
> included inline but it wasn't declared inline. That means you can either
> declare it inline or include it in exactly one translation unit.
>
> > I just wanted to know if I can
> > solve this problem using some compiler/linker flags.
>
> Possibly, look up linker settings, but you should fix the code instead of
> trying to work around it.
>
> 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]