Build and install 3D Slicer4 from source code in Windows

The 3D Slicer is a modern biomedical image processing and analysis software based on ITK and VTK libraries. It is an open source, and can be extended with plugins. Developing new modules, though, demands building the Slicer from the source code.

To say the truth, building Slicer in Windows (especially 64 bit Windows) is a pain. The official installation Wiki page is useful, but gives too many variants and options and jumping from one place to another with different prerequisites, prerequisites of prerequisites, etc., and finally forgets to tell you about essential Visual Studio switches. The result is: after a half day of building, you get between 1 to 5 unsuccessful builds…Who knows why…

After endless trials of installing different versions of different prerequisite softwares, here is my first successful installation list (VERY IMPORTANT to use the suggested software versions, and not newer versions):

  1. Install the newest version of Git.
  2. Install the newest version of SilkSVN.
  3. Install QT 4.7.4 (32 bit binary).
  4. Install VS 2008 Express with SP1.
  5. Install the newest version of CMake.
  6. Open the Windows file explorer and create the directory: C:\Slicer4
  7. Go to C:\ root directory, and press right mouse button. Choose Git Bash. When black terminal window opens, write and run:
    svn co Slicer4
  8. At this stage, the directory C:\Slicer4 should have all the source code of slicer.
  9. Go to Slicer4 directory, and create there Slicer4-Superbuild directory.
  10. Run CMake-GUI.
  11. Select…Where is the source code: C:\Slicer4
  12. Select…Where to build the binaries: C:\Slicer4\Slicer4-Superbuild
  13. Press Configure and select the generator Visual Studio 9 2008 (NOT Win64). If all the previous softwares were installed and configured properly, this step should run without any error messages, and give you a few selected red-background lines in the upper part of the GUI. If errors occur, this is probably because the system’s PATH is not updated properly (all binaries of all aforementioned programs should be included in the PATH variable.
  14. Press Configure once or twice until all the red disappears.
  15. Press Generate, and close CMake after the successful solution generation.
  16. Go to C:\Slicer4\Slicer4-Superbuild directory and open Slicer.sln with VS2008.
  17. When the project opens, select “Release” option instead of “Debug” on the upper toolbar (important!). Note that the built solution should be Win32 even when compiled on x64 machine and Win64.
  18. Build the solution. Hopefully, after a few hours of compiling, this should create a workable version of Slicer.


  • Once I’ve receive error for NUMPY build, and it was resolved by manually creating an empty NUMPY directory in the Slicer4-Superbuild directory, and recompiling.

15 responses to “Build and install 3D Slicer4 from source code in Windows

  1. thanks for the very instructive post,

    did you try if it is possible to compile with VS2010

  2. im asking because documentation of 4.0 and 4.1 is saying possible but 4.2 says its not working?

    • Well, both documents are right 🙂 It is possible to compile, but impossible to build…at least I don’t know how. The best way is to use the recommended VS2008 Express version.

  3. Thanks for the post! Useful

  4. Hi there,

    How are you able to build Slicer using a 32 bit VS when slicer is 64 bit?

    • The proposed steps should create 32 bit Slicer. Unless you’re interested in manipulating huge volumes of data, 32 and 64-bit versions are not really different. For 64 bit Slicer, you need to install different prerequisite soft.

      • I`m working with large sets of DICOM files and algorithms that won`t be able to run on 32 bit, so I`m currently trying to build 64 bit Slicer.

        Your steps are definitely a lot cleaner/frendlier than those on the Slicer website, though. 🙂

        Thanks for the reply!

  5. saima safdar

    Please help me with building a 64 bit slicer. What steps need changes? do I need to install latest versions for all the steps.

  6. saima safdar

    I need guidelines for building slicer on 64 bit machine windows. Please help. thanks.

  7. saima safdar

    Arie I am getting following errors while configuring with cmake. I followed the exact steps you mentioned but still

    CMake Error at SuperBuild/External_tbb.cmake:44 (message):
    At least Visual Studio 10.0 is required
    Call Stack (most recent call first):
    CMake/ExternalProjectDependency.cmake:842 (include)
    SuperBuild/External_VTKv9.cmake:14 (ExternalProject_Include_Dependencies)
    CMake/ExternalProjectDependency.cmake:842 (include)
    SuperBuild/External_teem.cmake:11 (ExternalProject_Include_Dependencies)
    CMake/ExternalProjectDependency.cmake:842 (include)
    SuperBuild.cmake:422 (ExternalProject_Include_Dependencies)
    CMakeLists.txt:722 (include)

  8. saima safdar

    Hello there I have configured and generated slicer.sln. I generated solution using VS express 2017. Now running in release mode in visual studio express 2017 but getting errors. the below is repeatedly coming.
    Severity Code Description Project File Line Suppression State
    Error C2065 ‘timezone’: undeclared identifier [C:\Slicer4\Slicer4-superbuild\python-build\CMakeBuild\libpython\libpython-shared.vcxproj] python c:\slicer4\slicer4-superbuild\python-2.7.13\modules\timemodule.c 713

    • Hello Saima,
      I haven’t compiled Slicer since 2013, so you need to take my advice with a grain of salt, but if their instructions say Visual Studio 10 or above, it probably means VS10 only (not VS2017 compatible), though in the instructions I see VS9 2008 and VS2010. Please try one of those.

  9. saima safdar

    thanks Arie. will let you know if I succeeded

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s