[Insight-developers] Multiple defined symbols :
ifstream/ofstream : Examples/OperatingRoom
Bill Hoffman
bill.hoffman@kitware.com
Mon, 24 Sep 2001 11:58:56 -0400
--=====================_1731114621==_.ALT
Content-Type: text/plain; charset="us-ascii"
msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: void __thiscall std::basic_ofstream<char,struct std::char_traits<char> >::`vbase destructor'(void)" (??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in liSpineModel.obj
msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: void __thiscall std::basic_ifstream<char,struct std::char_traits<char> >::`vbase destructor'(void)" (??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in liSpineModel.obj
That error is saying that the ofstream destructor is defined in msvcprt.lib and
liSplineModel.obj.
So it is a conflict with the standard library and liSplineModel.obj.
However, we use ostream stuff in other places in Insight with no problem.
What is different about liSplineModel ?
At 11:10 AM 9/24/2001 -0400, Luis Ibanez wrote:
>Hi,
>
>Now that /Examples is being built is easier to
>track some of the problems that only arise when
>full applications are built.
>
>The Dashboard is showing the error that originaly
>motivated the creation of the itkFstream class.
>
>The problem arises when std::ifstream or std::ofstream
>are used in two or more different .cxx files that
>later are linked together. std::ifstream and std::ofstream
>are templated classes, typically instantiated over <char>
>and <wchar> (this last one for supporting unicode).
>
>It seems that the implicit instatiation mechanism
>of VC++ generates the implemetation of these classes
>several times (I guess one for each .cxx it is used in).
>At linking time, these repeated implementations seems
>to be colliding. We use to set the "/force" keyword
>on Project/Settings/Link in order to force the linker
>to create an executable in spite of the collisions
>(hopping that the replicated implementations are
>truly identical).
>
>In an attempt to solve the problem, we typedefed
>std::ifstream in the class itkShape3D, and called
>IfstreamType, but that doesn't seems to be doing
>the trick..
>
>This is a VC++ specific problem. The same code is
>compiling and running smoothly under Linux.
>
>
>Any ideas ?
>
>Thanks
>
>Luis
>
>
>_______________________________________________
>Insight-developers mailing list
>Insight-developers@public.kitware.com
>http://public.kitware.com/mailman/listinfo/insight-developers
--=====================_1731114621==_.ALT
Content-Type: text/html; charset="us-ascii"
<html>
<b>msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: void
__thiscall std::basic_ofstream<char,struct
std::char_traits<char> >::`vbase destructor'(void)"
(??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ) already
defined in liSpineModel.obj <br>
</b>msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: void
__thiscall std::basic_ifstream<char,struct
std::char_traits<char> >::`vbase destructor'(void)"
(??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ) already
defined in liSpineModel.obj <br>
<br>
<br>
That error is saying that the ofstream destructor is defined in
msvcprt.lib and <br>
liSplineModel.obj.<br>
<br>
So it is a conflict with the standard library and
liSplineModel.obj.<br>
However, we use ostream stuff in other places in Insight with no
problem.<br>
What is different about liSplineModel ? <br>
<br>
<br>
<br>
At 11:10 AM 9/24/2001 -0400, Luis Ibanez wrote:<br>
<br>
<blockquote type=cite class=cite cite>Hi,<br>
<br>
Now that /Examples is being built is easier to<br>
track some of the problems that only arise when<br>
full applications are built.<br>
<br>
The Dashboard is showing the error that originaly<br>
motivated the creation of the itkFstream class.<br>
<br>
The problem arises when std::ifstream or std::ofstream<br>
are used in two or more different .cxx files that<br>
later are linked together. std::ifstream and std::ofstream<br>
are templated classes, typically instantiated over <char><br>
and <wchar> (this last one for supporting unicode).<br>
<br>
It seems that the implicit instatiation mechanism<br>
of VC++ generates the implemetation of these classes<br>
several times (I guess one for each .cxx it is used in).<br>
At linking time, these repeated implementations seems<br>
to be colliding. We use to set the "/force" keyword<br>
on Project/Settings/Link in order to force the linker<br>
to create an executable in spite of the collisions<br>
(hopping that the replicated implementations are<br>
truly identical).<br>
<br>
In an attempt to solve the problem, we typedefed<br>
std::ifstream in the class itkShape3D, and called<br>
IfstreamType, but that doesn't seems to be doing<br>
the trick..<br>
<br>
This is a VC++ specific problem. The same code is<br>
compiling and running smoothly under Linux.<br>
<br>
<br>
Any ideas ?<br>
<br>
Thanks<br>
<br>
Luis<br>
<br>
<br>
_______________________________________________<br>
Insight-developers mailing list<br>
Insight-developers@public.kitware.com<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-developers" eudora="autourl">http://public.kitware.com/mailman/listinfo/insight-developers</a>
</blockquote></html>
--=====================_1731114621==_.ALT--