[Insight-users] Linking to shared MinGW build of ITK not possible

Zelzer Sascha s.zelzer at dkfz-heidelberg.de
Tue Oct 13 12:50:57 EDT 2009


Hi,

 

I built ITK 3.14 successfully with MinGW (gcc 4.4) with
BUILD_SHARED_LIBS=ON. However, when I try to build my project which
depends on ITK, the linker complains about multiple definitions of
symbols in ITKCommon.dll.a and libitkvnl.a (for example).

 

It seems that the transitive library dependencies, which CMake generates
for my shared library, are incorrect since ITKCommon already links
statically to itkvnl but libitkvnl.a ist still present in the list of
libraries to be linked.

 

If I change the following lines in ITKs CMakeLists.txt from

 

407: IF(WIN32)

408:   IF(BUILD_SHARED_LIBS)

409:     SET(ITK_COMMON_BUILD_TYPE "SHARED")

410:   ELSE(BUILD_SHARED_LIBS)

411:     SET(ITK_COMMON_BUILD_TYPE "STATIC")

412:   ENDIF(BUILD_SHARED_LIBS)

413:   SET(BUILD_SHARED_LIBS OFF)

414: ENDIF(WIN32)

 

to

 

407: IF(WIN32 AND NOT MINGW)

408:   IF(BUILD_SHARED_LIBS)

409:     SET(ITK_COMMON_BUILD_TYPE "SHARED")

410:   ELSE(BUILD_SHARED_LIBS)

411:     SET(ITK_COMMON_BUILD_TYPE "STATIC")

412:   ENDIF(BUILD_SHARED_LIBS)

413:   SET(BUILD_SHARED_LIBS OFF)

414: ENDIF(WIN32 AND NOT MINGW)

 

and correct the export/import defines in
Utilities/gdcm/src/gdcmCommon.h:81 

 

from #ifdef gdcm_EXPORTS to #ifdef itkgdcm_EXPORTS

 

the utility libraries are build as shared libraries and everything links
fine to my project.

 

Is this a known bug, a CMake problem, or a misconfiguration on my side?

 

Thanks,

Sascha

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091013/906e0e44/attachment.htm>


More information about the Insight-users mailing list