MantisBT - ITK
View Issue Details
0012028ITKITKpublic2011-03-30 13:342011-04-07 09:28
Martin Bergtholdt 
Brad King 
normalmajoralways
closedfixed 
Visual Studio 9 2008 Win64Windows-7Windows-7
ITK-4-A3 
 
backlog
0012028: BUILD_SHARED_LIBS no longer possible using MSVC, therefore no wrappers possible
A few weeks ago it seems that building shared libraries using msvc has become impossible. The reason is the CMake include ITKPlatformSpecificChecks.cmake which disables BUILD_SHARED_LIBS for non GNU compilers. I can therefore no longer build Python wrappers using WrapITK since in itkWrapSetup.cmake this produces an error:

  if(NOT BUILD_SHARED_LIBS)
    message(FATAL_ERROR "Wrapping requires a shared build, change BUILD_SHARED_LIBS to ON")
  endif(NOT BUILD_SHARED_LIBS)
Set these CMake options:

BUILD_SHARED_LIBS=ON
ITK_BUILD_ALL_MODULES=ON
ITK_USE_REVIEW=ON
USE_WRAP_ITK=ON
WRAP_ITK_PYTHON=ON

BUILD_SHARED_LIBS is reset to OFF once ITKPlatformSpecificChecks.cmake is included. WrapITK consequently complains that BUILD_SHARED_LIBS is OFF. This was rather hard to find out where BUILD_SHARED_LIBS was turned OFF
BUILD_SHARED_LIBS OFF should not be silently done, it is really hard to figure this out!

Will it be impossible to compile wrappers for ITK 4.0 using MSVC?
msvc, shared, WrapITK
Issue History
2011-03-30 13:34Martin BergtholdtNew Issue
2011-03-30 13:36Martin BergtholdtTag Attached: msvc
2011-03-30 13:36Martin BergtholdtTag Attached: WrapITK
2011-03-30 13:36Martin BergtholdtTag Attached: shared
2011-04-01 10:18Hans JohnsonAssigned To => Bill Lorensen
2011-04-01 10:18Hans JohnsonStatusnew => assigned
2011-04-01 10:19Hans JohnsonNote Added: 0026010
2011-04-01 15:38Brad KingNote Added: 0026024
2011-04-01 15:40Brad KingNote Added: 0026025
2011-04-04 14:36Brad KingAssigned ToBill Lorensen => Gaetan Lehmann
2011-04-04 14:36Brad KingNote Added: 0026084
2011-04-06 13:37Brad KingNote Added: 0026125
2011-04-07 09:28Brad KingAssigned ToGaetan Lehmann => Brad King
2011-04-07 09:28Brad KingNote Added: 0026135
2011-04-07 09:28Brad KingStatusassigned => closed
2011-04-07 09:28Brad KingResolutionopen => fixed

Notes
(0026010)
Hans Johnson   
2011-04-01 10:19   
Bill,

I just assigned this to you because you seem to have been working on these issues lately. Feel free to pass the hot potato to someone else if needed.

Hans
(0026024)
Brad King   
2011-04-01 15:38   
We have to force BUILD_SHARED_LIBS to OFF within most of the tree because we don't actually support shared libraries on Windows, except for ITK-Common which is set up as a special case. The reason is that the numerics library, vnl, does not have proper dllexport markup because it is very tricky to do with the library's manual instantiation approach. This has always been the case since ITK started.

The problem is with when the check for wrapping is done.

Prior to modularization the itkWrapSetup code was loaded before the BUILD_SHARED_LIBS changes:

  http://itk.org/gitweb?p=ITK.git;a=blob;f=CMakeLists.txt;hb=v4.0a06#l356 [^]

Then the main Wrapping directory was added later:

  http://itk.org/gitweb?p=ITK.git;a=blob;f=CMakeLists.txt;hb=v4.0a06#l828 [^]

Now both are included near the bottom of the file:

  http://itk.org/gitweb?p=ITK.git;a=blob;f=CMakeLists.txt;hb=fd4805a3#l503 [^]
(0026025)
Brad King   
2011-04-01 15:40   
I think this can be fixed simply by changing the check in wrapping setup to inspect ITK_BUILD_SHARED_LIBS instead of BUILD_SHARED_LIBS. The former is set to record the original value of the latter before forcing it OFF.
(0026084)
Brad King   
2011-04-04 14:36   
Gaetan, please confirm that checking ITK_BUILD_SHARED_LIBS is enough for Wrapping.
(0026125)
Brad King   
2011-04-06 13:37   
Martin, if you edit Wrapping/itkWrapSetup.cmake and replace BUILD_SHARED_LIBS with ITK_BUILD_SHARED_LIBS, the complaint should go away. Does the build work after that?
(0026135)
Brad King   
2011-04-07 09:28   
http://itk.org/gitweb?p=ITK.git;a=commitdiff;h=840999df [^]