build fails on Windows 64

I am trying to build sitk on Windows 64 but the build fails. Using cmake for windows it generates only utility projects. I can see some libraries have been built, but no generated header files. The file “SimpleITKBasicFiltersGeneratedHeaders.h” can not find any of its includes. I am not sure how to proceed with this.

Hello and welcome to the ITK community!

The instructions for building the previous release of SimpleITK 2.5.3 are here:

The current development of SimpleITK 3.0 is underway and the CMake infrastructure is under going some major changes (unstable) in the main branch. So please use the release branch to a tag if you are building from source.

What are you building SimpleITK for? Python bindings? or C++ interface?

Please provide some details about what code you downloaded, how you configured, and what the build output is so that we can assist you.

1 Like

Thanks for the reply. I am building sitk for windows 64 for C++. I have downloaded the source code version 2.5.3 and did a Superbuild using cmake for Windows. The generated projects were all Utility projects, none of them were libs. I am suspecting that the LUA version is not correct, I used the latest one 5.5.0 although I am not getting error messages from the cmake file about the version it keeps getting wiped everytim I run a configure on cmake. I will try a lower LUA version and see what happens. I read the build instructions and I can see now that the build downloaded LUA 5.4.7 and swing 4.4. I will try buildoing with these versions and see what happens.

I downloaded a loer LUA version, 5.1, and this is the error I got

CMake Error at C:/Program Files/CMake/share/cmake-4.2/Modules/FindPackageHandleStandardArgs.cmake:290 (message):
Could NOT find LuaInterp: Found unsuitable version “5.1.5”, but required is
at least “5.3” (found D:/Libraries/Lua-5.1/lua.exe)

I am not able to find a version 5.3 for windows on the LUA site. Is this supposed to be there in the make file? Should I edit the make file to drop the requirement?

Please start with a clear build directory, then configure CMake with the source directory as the “SuperBuild” sub-directory from the SimpleITK source code: Building SimpleITK — SimpleITK 2.4.0 documentation

Using the super build it will provide the correct version of Lua, SWIG, and ITK expected for the SimpleITK build.

1 Like

I followed the build instructions you mentioned, and still I got this error:

cl error D8021: invalid numeric argument ‘/Wno-invalid-offsetof’ [D:\Libraries\SimpleITK\SuperBuild\build\SimpleITK-build\CMakeFiles\CMakeScratch\TryCompile-jyjz4n\cmTC_387ac.vcxproj]

However this time some of the missing generated header files were generated, but not all of them.

I checked the log file for the different generated projects.

this is the error from the SimpleITK project:

“D:\Libraries\SimpleITK\SuperBuild\build\SimpleITK.vcxproj” (Build target) (1) →
(CustomBuild target) →
MSBUILD : error MSB1009: Project file does not exist.

error from the SimpleITK-build project:

“D:\Libraries\SimpleITK\SuperBuild\build\SimpleITK-build.vcxproj” (Build target) (1) →
(CustomBuild target) →
MSBUILD : error MSB1009: Project file does not exist.

same for the SimpleITK-configure, SimpleITK-Examples, _ENV

Finally after 3 days of working on the build I was able to compile all projects included. There is code missing though that I had to add to make things compile. I also removed all the wrapping. The make file needs some work apparently.

Glad you were able to get SimpleITK to build for yourself.

I am unfortunately unable to reproduce your issue. And you didn’t share any specific modifications to the CMake configuration files to provide an insight into your issue. It sounds like you may not be having a correct configuration out of the box with SimpleITK, and some changes in CMake configuration variables are needed.

1 Like

The problem now is that the generated libs are dynamic link libs, I am using static linke dlibs. I adjusted the cmake flags in the cmake for windows to MTd yet the libearies are still dynamic libs. How do I generate static linked libs?

For ITK “ITK_MSVC_STATIC_RUNTIME_LIBRARY” should be set to ON. For SimpleITK you may need to manually set “CMAKE_MSVC_RUNTIME_LIBRARY” to “MultiThreaded$<$CONFIG:Debug:Debug>”.

You may find more information here: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html

Thank you. Also regarding the downloaded code. There are 2 missing definitions, one is for the struct “IsSame” and the other is for a macro I think it is called something like RETRUN_SELF_TYPE or something close to that. The code would not compile without these definitions. I can provide the code to them if needed but I would have o go back and look for them.

If you have a set of tool you are using and sequence of command line to reproduce your issue it would be helpful to identify the underlying configuration issues. Full output of the steps would also be useful.

I just use cmake for windows to configure, visual studio to build and msbuild to see the build errors and then it is just going after the errors. I would like to suggest that in the next release do not use Utility projects for the MSVC build, just use library projects. It is extremely difficult to reconfigure Utility projects. Changing a default configuration, like a dynamic lib build into a static lib is not an easy and straight path with a Utility project, adding a library to link to or any such configuration changes is also very hard to do.

Maybe running cmake --config Release --build . in the root of the generated project from the SimpleITK build directory would address some issue. The projects generated by cmake are not designed to be modified.

1 Like

The problem is not release vs debug, it is dynamic vs static version. I am trying to trace how this is done in the make files of the project.

I am still unable to figure out where to set the build to be static debug and not dynamic debug libs. Anyone has any idea where this is done in the configuration or cmake files? I have tried many things but none of them has worked so far. I see the BUILD_SHARED_LIBS variable but have not been able to find where to set it at the top. I have #undef it in different places but it keeps getting reset by some other config or cmake file somewhere.

During each reconfiguration, CMake regenerates Visual Studio projects, removing any custom changes you have made. To enable static CRT, you should add /MT and MTd flags to CMAKE_CXX_FLAGS_RELEASE etc. Using CMake GUI, that looks something like this (I highlighted interesting things for you in yellow):

1 Like

Do I need to link to itk libs when building with sitk?