[Insight-developers] Multiply defined symbols with MSVC and BUILD_SHARED_LIBS=ON
Tom Vercauteren
tom.vercauteren at m4x.org
Mon May 10 13:55:33 EDT 2010
Hi all,
I am trying to help a fellow developer with building a project that
uses ITK on windows. The project needs shared libraries because of a
plugin mechanism.
Hence ITK was built with BUILD_SHARED_LIBS=ON. Building our project
fails at link time with the following error message:
ITKNrrdIO.lib(miscAir.obj) : error LNK2005: _itk_airFree already
defined in mydll.lib(mydll.dll)
fatal error LNK1169: one or more multiply defined symbols found
This arises each time we build an executable X that links with ITK and
with another shared libray A that also links with ITK.
I have filled a bug report here:
http://www.itk.org/Bug/view.php?id=10699
Does anyone have a fix or a work-around for this problem?
Apparently, the same problem has been in ITK for a while but was
appearing with different symbols but my fellow developer apparently
managed to work-around it previously by carefully picking when to link
with what. I guess that this was only due to the fact that we were
never in a more complex scenario that we now see:
X links with A and B. Both A and B link with some ITK library.
A wild guess from my part would be that this could be related to the
ITK_EXPORT macro. My basic understanding (I am not a regular windows
developer) is that visual c++ requires one specific export/import
macro per dll. ITK only uses ITKCommon_EXPORT and goes away with it by
only building one shared library (ITKCommon.dll) while the other are
built as static ones. This looks a bit weird to me. Could someone
explain me the rationale of this approach?
Cheers,
Tom
More information about the Insight-developers
mailing list