[Insight-developers] Multiple defined symbols : ifstream/ofstream : Examples/OperatingRoom

Luis Ibanez ibanez@choroid.cs.unc.edu
Mon, 24 Sep 2001 11:10:46 -0400 (EDT)


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