[vtkusers] Compiling VTK with MinGW, fixes to CMake rules

Mathieu Malaterre mathieu.malaterre at kitware.com
Wed Sep 14 12:11:56 EDT 2005


Kalle,

	VTK is being compiled every night with the following ctest script:

http://www.vtk.org/Testing/Sites/ARRAKIS.kitware/Win32-mingw/20050914-0300-Nightly/Notes.html

	It does not involve any kind of modification neither in VTK source nor 
in cmake source. Could you please tell us what commands you use to 
create those problems ?

Thanks
Mathieu

Kalle Pahajoki wrote:
> Hi
> 
> I've been compiling VTK with MinGW for a while now and I've had two 
> problems with the CMake generated makefiles:
> 1) they name the generated libraries libvtk<something>.dll when they 
> should be vtk<something>.dll
> 2) the flag -lgcc should not be there
> 
> So far I've worked around this by fixing the makefiles after they've 
> been generated (with a shell script) but that's slow and complex.
> So I took some time to figure out  if I could get proper makefiles 
> generated instead of fixing them afterwards.
> Here are my preliminary results, which seem to work fine.
> 
> I edited the C:\Program files\Cmake20\Modules\Platform\Windows-gcc.cmake 
> and added the following block of code (which is adapted from the 
> Cygwin.cmake):
> 
> IF(CMAKE_COMPILER_IS_MINGW)
>    SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared 
> -Wl,--export-all-symbols -Wl,--enable-auto-import")
>    SET(CMAKE_DL_LIBS "-lgdi32" )
>    SET(CMAKE_SHARED_LIBRARY_PREFIX "")
>    SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")
>    # no pic for gcc on cygwin
>    SET(CMAKE_SHARED_LIBRARY_C_FLAGS "")
>    SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
> ENDIF(CMAKE_COMPILER_IS_MINGW)
> 
> The C:\program files\cmake20\modules\CMakeDefaultMakeRuleVariables.cmake 
> has the following lines:
> 
> IF(CMAKE_COMPILER_IS_GNUCXX)
>    SET(CMAKE_CXX_CREATE_SHARED_LIBRARY 
> "${CMAKE_CXX_CREATE_SHARED_LIBRARY} -lgcc")
> ENDIF(CMAKE_COMPILER_IS_GNUCXX)
> 
> I modified them to read:
> 
> IF(CMAKE_COMPILER_IS_GNUCXX)
>  IF(NOT CMAKE_COMPILER_IS_MINGW)
>    SET(CMAKE_CXX_CREATE_SHARED_LIBRARY 
> "${CMAKE_CXX_CREATE_SHARED_LIBRARY} -lgcc")
>  ENDIF(NOT CMAKE_COMPILER_IS_MINGW)
> ENDIF(CMAKE_COMPILER_IS_GNUCXX)
> 
> With these changes, the generated Makefiles seem to work correctly. I 
> feel a bit stupid for wasting so much time repairing bad makefiles when 
> it took less than an hour to figure this out.
> 
> Hopefully someone finds this useful.
> 
> Kalle
> 
> 




More information about the vtkusers mailing list