Running Cura from Source on Windows - Ultimaker/Cura Wiki

Contents

  1. Alternative method
  2. Microsoft Visual Studio
  3. CMake
  4. mingw-w64
  5. Git (Optional)
  6. Python 3.8.10
  7. Compiled Libraries
  8. Uranium
  9. CuraEngine
  10. Cura

Note

These instructions are taking for granted that the user is using a Windows 10 machine with a Windows version >= 1809 (i.e., OS Build 17763). In order to check your version of Windows you can either click on 'Start' and write winver and press Enter or using powershell you can enter:

PS > [System.Environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      17763  0

This guide was tested and performed on a 20H2 Windows version (i.e., OS Build 19042). Please note that Windows 10 versions earlier than 1809 or Windows Operating Systems such as Windows 7, 8 or 8.1 are not taken into account in this guide.

Alternative method

Before we begin this guide, we should mention that "officially", Cura is built as follows:

As a result, at this point you can choose whether you would like to follow the "official" path with all the problems it might entail for each user/OS installation or you can continue with the following steps and install the dependencies manually. If you choose for the former option please refer to the respective repositories to view the actual steps you will need to take for installing each.

Microsoft Visual Studio

For compiling the libraries on Windows, Microsoft Visual Studio C++ is required. Microsoft Visual Studio 2019 is supported.

Microsoft Visual Studio 2019 (recommended install)

(Also works with VS2022, but make sure to install MSVC v142 - VS 2019 C++ build tools (v16.00) compatibility kit then too.)

  1. Download Microsoft Visual Studio 2019 from here (Web Installer). The free version is the Community edition.
  2. Run the web installer. It will take some time to download everything needed.
  3. When the installer loads, check Desktop development with C++ under Windows. Also select MSVC v140 - VS 2015 C++ build tools (v14.00) under Installation details. The complete installation will be large (>6 GB) and will take a while to complete. (This step might not be necessary anymore for VS2022 and/or the current build.)
  4. When building files (using cmake or nmake) in the steps below be sure to use the 'x64 Native Tools Command Prompt for VS 2019'. This ensures that the Visual Studio 2019 build tools are used.

Microsoft Visual Studio 2015 (used on earlier builds)

(Might not work anymore for all repo's, notably the (lib)pynest build part. You can probably still make it work, but some own research is required.)

  1. Download Microsoft Visual Studio from here (Web Installer) or here (ISO Image).
  2. Run the installer. To save on space, Custom can be selected with only Visual C++ selected in Programming Languages. The complete installation will be large (>12 GB) and will take a while to complete.

CMake

  1. Download CMake for Windows "win64-x64" from here.
  2. Run the installer.
  3. When selecting the PATH option, select either Add CMake to system PATH for all users or Add CMake to the system PATH for the current user. The allows the cmake command to be run from the command line.
  4. Verify the installation of CMake by opening up a command window and typing cmake --version.

MinGW-w64

MinGW-w64 is needed if you are building the CuraEngine. If only the libraries are being compiled, this can be skipped.

  1. Download the mingw-w64 installer (not the zip) from here.
  2. Run the installer. The architecture should be changed to x86_64 and the threading architecture should be posix (pthread).
  3. Add MinGW to the PATH environment containg the bin directory (e.g., C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin).
  4. Check if mingw32-make can be found by opening a terminal and typing 'mingw32-make'. It should say 'No targets specified and no makefile found. Stop.'

Git (Optional)

Git is recommended for cloning the other repositiories using the command line. Git is not required since all of the files can be downloaded repositories.

  1. Download Git for Windows from here.
  2. Run the installer. Select either Git from command line and also from 3rd-party software (default) or Use Git and optional Unix tools from the Command Prompt are selected in the Adjusting your PATH environment section.
  3. Verify the installation of git by opening up a command window and typing git --version.

Python 3.8.10

  1. Download Python 3.8.X from here (3.8.10).
  2. Before using Install Now or Customize installation, check Add Python 3.8 to PATH so it can be referenced in the command line.
  3. Verify the install of Python by opening up a command window and typing python --version. Also verify that pip3 (the tool for installing packages) is installed by typing python -m pip --version. If either of them aren't working, make sure the Windows PATH variable contains both the root directory of Python (like %localappdata%/Programs/Python/Python38/) and the Scripts folder (like %localappdata%/Programs/Python/Python38/Scripts).
  4. Download the Numpy library from here using the MKL version for your Python version (3.8) and using the 64-bit version of the installation for 64-bit installations. It can be installed using pip3 install [WHL FILE] in the command line.
  5. Download the Shapely library from here using the cp38‑cp38m‑win32.whl version for 32-bit installs and the cp38‑cp38m‑win_amd64.whl version for 64-bit installs. It can be installed using pip3 install [WHL FILE] in the command line.
  6. Install the other required libraries using:
    python -m pip install scipy cryptography colorlog netifaces zeroconf trimesh sentry_sdk pyserial PyQt5==5.15.2 keyring requests pywin32 
    
    Note: PyQt5 Version 5.15.2 is specifically required. (If this fails, however, try with the newest 5.15.x)

Compiled Libraries

Compiling the libraries requires using the 'x64 Native Tools Command Prompt for VS 2019' that is installed with Microsoft Visual Studio. This allows the nmake command to be used. Since compling some of the libraries requires referencing other libraries, the steps will us a C:/dev directory. Any directory can be used as long as the changes are made when running the commands.

Protobuf

  1. Download Protobuf 3.15.7 from here.
  2. Extract it to C:/dev so that you then have a C:/dev/protobuf-3.15.7 directory.
  3. Navigate to the protobuf-3.15.7 directory:
    cd C:/dev/protobuf-3.15.7
    
  4. Create the build and install directories.
    mkdir install_dir
    mkdir cmake_build && cd cmake_build
    
  5. Build and install Protobuf:
    cmake -DCMAKE_INSTALL_PREFIX=../install_dir -DCMAKE_INSTALL_LIBDIR=lib -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles" ../cmake
    nmake
    nmake install
    

SIP

  1. Download SIP 4.19.25 from here.
  2. Extract it to C:/dev so it creates a C:/dev/sip-4.19.25 directory. The last part of the version should be removed from the name.
  3. Navigate to the sip-4.19.25 directory:
    cd C:/dev/sip-4.19.25
    
  4. Build and install SIP (again making sure to use the command prompt provided by Visual Studio):
    python configure.py
    nmake
    nmake install
    

Arcus

  1. Clone the libArcus repository:
    git clone -b "build_from_source_windows" https://github.com/Ultimaker/libArcus.git C:\dev\libArcus
    
  2. Navigate to the libArcus directory:
    cd C:\dev\libArcus
    
  3. Create the build directory:
    mkdir install_dir
    mkdir build && cd build
    
  4. Set the environment variables for Protobuf:
    set PROTOBUF_SRC=C:\dev\protobuf-3.15.7
    set PROTOBUF_INSTALL=%PROTOBUF_SRC%\install_dir
    
  5. Build and install libArcus (again making sure to use the command prompt provided by visual studio):
    cmake -DCMAKE_INSTALL_PREFIX=../install_dir -DPROTOBUF_SRC_ROOT_FOLDER=%PROTOBUF_SRC% -DPROTOBUF_LIBRARY=%PROTOBUF_INSTALL%/lib/libprotobuf.lib  -DPROTOBUF_INCLUDE_DIR=%PROTOBUF_INSTALL%/include -DPROTOBUF_PROTOC_EXECUTABLE=%PROTOBUF_INSTALL%/bin/protoc.exe -DBUILD_EXAMPLES=OFF -DBUILD_STATIC=ON -DMSVC_STATIC_RUNTIME=ON -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles" ..
    nmake
    nmake install
    

Savitar

  1. Clone the libSavitar repository:
    git clone https://github.com/Ultimaker/libSavitar.git C:\dev\libSavitar
    
  2. Navigate to the libSavitar directory:
    cd C:\dev\libSavitar
    
  3. Create the build and install directories:
    mkdir install_dir
    mkdir build && cd build
    
  4. Build and install libSavitar (again making sure to use the command prompt provided by visual studio):
    cmake -DCMAKE_INSTALL_PREFIX=../install_dir -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles" ..
    nmake
    nmake install
    

Charon

Note that Cura might run without libCharon as well, but at least the UFP-reader plugin will be disabled then.

  1. Clone the libCharon repository:

    git clone https://github.com/Ultimaker/libCharon.git C:\dev\libCharon
    
  2. Navigate to the libCharon directory:

    cd C:\dev\libCharon
    
  3. Create the build and install directories:

    mkdir install_dir
    mkdir build && cd build
    
  4. Build and install libCharon (again making sure to use the command prompt provided by visual studio):

    cmake -DCMAKE_INSTALL_PREFIX=../install_dir -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles" ..
    nmake
    nmake install
    
  5. Manually move/copy the folder named Charon in the ./lib/python<version>/site-packages-subfolder in the install-directory made in step 3. to the site-packages folder of your python-installation. Typically this will look something like \Users\<username>\AppData\Local\Programs\Python\Python<version>\Lib\site-packages.


Pynest2D

  1. Clone the Ultimaker libnest2d repository:

    git clone https://github.com/Ultimaker/libnest2d.git C:\dev\libnest2d
    
  2. Navigate to the libnest2d directory:

    cd C:\dev\libnest2d
    
  3. Create the build and install directories:

    mkdir install_dir
    mkdir build && cd build
    
  4. (Optional) If you already have boost in your system make sure that it doesn't appear when building libnest2D:

    set BOOST_ROOT=
    
  5. Build and install libnest2d, instructing it to download and build its dependencies too (-DRP_ENABLE_DOWNLOADING=ON):

    cmake .. -DLIBNEST2D_HEADER_ONLY=OFF -DRP_ENABLE_DOWNLOADING=ON -DCMAKE_INSTALL_PREFIX=..\install_dir
    cmake --build . --target install
    

    Note: If you don't want libnest2d to automatically download and install the necessary dependencies (boost, NLopt, Clipper), then remove the flag -DRP_ENABLE_DOWNLOADING=ON and make sure you have these dependencies installed in your system

  6. Clone the pynest2d repository:

    git clone https://github.com/Ultimaker/pynest2d.git C:\dev\pynest2d
    
  7. Navigate to the pynest2d directory:

    cd C:\dev\pynest2d
    
  8. Create the build and install directories:

    mkdir install_dir
    mkdir build && cd build
    
  9. Set the required environment variables:

    set CLIPPER_PATH=C:\dev\libnest2d\build\dependencies
    set NLopt_PATH=C:\dev\libnest2d\build\dependencies
    set BOOST_ROOT=C:\dev\libnest2d\build\dependencies
    

    Note: If you did not download these dependencies using libnest2d, then set the correct paths in your system

  10. Build and install pynest2d (again making sure to use the command prompt provided by visual studio):

    cmake -DCMAKE_INSTALL_PREFIX=../install_dir -DLIBNEST2D_INCLUDE_DIRS=C:\dev\libnest2d\install_dir\include -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles" ..
    nmake
    nmake install
    

Uranium

Uranium, or UM, is a required library, but does not need to be compiled.

  1. Clone the Uranium repository:
    git clone https://github.com/Ultimaker/Uranium.git C:\dev\Uranium
    
  2. Add the Uranium directory to your PYTHONPATH environment variable. It can be done with the following command, even if PYTHONPATH is not set up:
    set PYTHONPATH=%PYTHONPATH%;C:\dev\Uranium
    

If you decide to add UM to the main Python install, the contents of the plugins and resources directories will need to be copied to the C:\dev\Cura\plugins and C:\dev\Cura\resources directories respectively when the Cura repository is cloned.

CuraEngine

Note: Certain libraries will be built again. This is intentional, since we need mingw for the engine (and we need the nmake for the sip dependencies!).

  1. Download Protobuf 3.15.7 from here.
  2. Extract it to C:\dev with a -mingw suffix so it creates a C:/dev/protobuf-3.15.7-mingw directory.
  3. Navigate to the protobuf-3.15.7-mingw directory:
    cd C:\dev\protobuf-3.15.7-mingw
    
  4. Create the build and install directories.
    mkdir install_dir
    mkdir cmake_build && cd cmake_build
    
  5. Build and install Protobuf:
    cmake -DCMAKE_INSTALL_PREFIX=../install_dir -DCMAKE_PREFIX_PATH=../install_dir -DCMAKE_INSTALL_LIBDIR=lib -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_CXX_FLAGS="-std=c++11" -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" ../cmake
    mingw32-make
    mingw32-make install
    
  6. Clone the libArcus repository with a -mingw suffix:
    $ git clone https://github.com/Ultimaker/libArcus.git C:\dev\libArcus-mingw
    
  7. Navigate to the libArcus-mingw directory:
    cd C:\dev\libArcus-mingw
    
  8. Create the build directory:
    mkdir install_dir
    mkdir build && cd build
    
  9. Set the environment variables for Protobuf:
    set PROTOBUF_MINGW_SRC=C:/dev/protobuf-3.15.7-mingw
    set PROTOBUF_MINGW_INSTALL=%PROTOBUF_MINGW_SRC%/install_dir
    
  10. Build and install libArcus:
    cmake -DCMAKE_INSTALL_PREFIX=../install_dir -DPROTOBUF_SRC_ROOT_FOLDER=%PROTOBUF_MINGW_SRC% -DPROTOBUF_LIBRARY=%PROTOBUF_MINGW_INSTALL%/lib/libprotobuf.a -DPROTOBUF_INCLUDE_DIR=%PROTOBUF_MINGW_INSTALL%/include -DPROTOBUF_PROTOC_EXECUTABLE=%PROTOBUF_MINGW_INSTALL%/bin/protoc -DBUILD_EXAMPLES=OFF -DBUILD_STATIC=ON -DBUILD_PYTHON=OFF -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" ..
    mingw32-make
    mingw32-make install
    
  11. Clone the CuraEngine repository:
    git clone https://github.com/Ultimaker/CuraEngine.git C:\dev\CuraEngine
    
  12. Navigate to the CuraEngine directory:
    cd C:\dev\CuraEngine
    
  13. Create the build and install directories.
    mkdir install_dir
    mkdir cmake_build && cd cmake_build
    
  14. Set the environment variables for Arcus:
    set ARCUS_DIR=C:/dev/libArcus-mingw/install_dir/lib/cmake/Arcus
    
  15. Build and install CuraEngine:
    cmake -DCMAKE_INSTALL_PREFIX=../install_dir -DCMAKE_BUILD_TYPE=Release -DArcus_DIR=%ARCUS_DIR% -DPROTOBUF_SRC_ROOT_FOLDER=%PROTOBUF_MINGW_SRC% -DPROTOBUF_LIBRARY=%PROTOBUF_MINGW_INSTALL%/lib/libprotobuf.a -DProtobuf_INCLUDE_DIR=%PROTOBUF_MINGW_INSTALL%/include -DPROTOBUF_PROTOC_EXECUTABLE=%PROTOBUF_MINGW_INSTALL%/bin/protoc.exe -DPROTOC=%PROTOBUF_MINGW_INSTALL%/bin/protoc.exe -G "MinGW Makefiles" ..
    mingw32-make
    mingw32-make install
    

Cura

  1. Clone the Cura repository:
    git clone https://github.com/Ultimaker/Cura.git C:\dev\Cura
    
  2. Clone the fdm_materials in the resources/materials directory of Cura:
    git clone https://github.com/Ultimaker/fdm_materials.git C:\dev\Cura\resources\materials
    
  3. Navigate to the Cura directory:
    cd C:\dev\Cura
    
  4. Add the CuraEngine executable:
    copy "C:\dev\CuraEngine\install_dir\bin\CuraEngine.exe" CuraEngine.exe
    
  5. Run Cura:
    python cura_app.py