Running Slic3r from git on Windows - slic3r/Slic3r GitHub Wiki

Slic3r in source code form could be run with Perl and its dependencies installed. It has been tested with CitrusPerl and StrawberryPerl.

You need to get the source, install Perl, its dependencies to get Slic3r runs. The steps are outlined below.

Installing a Perl for Windows

You can choose between Citrus Perl or Strawberry Perl. Either will do. They include MinGW which facilitates installing additional Perl modules.

Citrus Perl installs cleanly into a standalone folder and won't touch the Windows system in any ways. MinGW is downloaded separately (though automatically). At the time of writing, 3D preview won't work with Citrus Perl on 64-bit Windows because its MinGW lacks FreeGLUT.

Strawberry Perl comes with the MinGW packaged in an MSI installer, and touch the environment variable such that it integrates itself into the Windows shell. Side by side installation of different versions would be difficult if not impossible.

Because of a known issue that is a combination of newer gcc versions, SJLJ exceptions, and Perl exceptions, use the following custom Strawberry Perl 5.24 build that packages GCC 6.3.0 using SEH exceptions. If using 32-bit, then use regular Strawberry Perl instead.

Strawberry Perl 5.26 should be compatible (as it uses GCC7 and SEH exceptions).

Slic3r Perl

  • Download Slic3r Perl.
  • Install it by following the on screen instructions. Basically that means keep clicking Next.
  • Now your command prompt is loaded with Perl. You start the command prompt with...
    • In the Start Menu, All Programs, then Accessories, finally Command Prompt
    • Press Win+R, type cmd, then Enter.
    • For Vista/Windows 7: open the Start menu, type cmd in the search box, then Enter.

Strawberry Perl (32-bit only)

  • Download Strawberry Perl 5.24 (or newer) from http://strawberryperl.com/
  • Install it by following the on screen instructions. Basically that means keep clicking Next.
  • Now your command prompt is loaded with Perl. You start the command prompt with...
    • In the Start Menu, All Programs, then Accessories, finally Command Prompt
    • Press Win+R, type cmd, then Enter.
    • For Vista/Windows 7: open the Start menu, type cmd in the search box, then Enter.

Now continue with installing the dependencies section.

Citrus Perl

  • Download CitrusPerl 5.14 (preferred over 5.12) from http://www.citrusperl.com/download.html
  • Extract the zip to a folder. Choose a reasonable place, like C:\dev\CitrusPerl, as you won't be able to move it after the installation.
  • Run citrusutils.exe in C:\dev\CitrusPerl\bin
  • A window called citrusutils will be opened.
    • Click the "Set GCC" button to set the GCC compiler.
    • Select "Download the binary MinGW distribution used to build this Perl" and click Ok. It will now start downloading the compiler.
    • Select the Folder where you would like to install the compiler and click Ok. (You could ask it to extract to C:\dev\CitrusPerl too)
    • You can now close the citrusperl utilities.
  • Run citrusterm.bat in C:\dev\CitrusPerl\bin (it might be called citrusterm32.bat if you downloaded the 32-bit version), and you get a command prompt with Perl environment ready.
  • Then issue the following command:
cpan JSON App::cpanminus

You will need to open the citrusterm prompt every time you want to launch Slic3r, or run Perl for that matters. Now continue with the installing dependencies section.

Installing the dependencies

Installing the Boost libraries

Slic3r is known to work with Boost 1.63.0. Note: Dev version prior to 27/03/2017 worked ok with boost 1_59_0. If you have that installed, you need to erase the folder c:\dev\boost_1.59_0\ and then install and compile the new boost libraries, following the next instructions

Download them from the Boost website. The official binaries won't work since they're compiled for MSVC. Extract the sources to C:\dev\boost_1_63_0. Run the following instructions from the Perl command prompt

cd C:\dev\boost_1_63_0
bootstrap.bat gcc
b2 toolset=gcc address-model=64 cxxflags="-std=c++11" link=static runtime-link=static variant=release threading=multi

Getting the Perl module dependencies

For our custom Perl package of 5.24, use the prebuilt dependency archive. It includes wxWidgets 3.1.0, because wxWidgets 3.0.2 does not build with newer GCC versions. See Building wxWidgets 3.1.0 for more information about custom-building wxWidgets if you really want to build it yourself.

For Strawberry Perl 5.24.0 (32bit) and 5.18.3 (64bit), there is an archive of the local-lib directory, which speeds things up markedly and avoids some common issues with building dependencies: https://bintray.com/lordofhyphens/Slic3r/Slic3r_Dependencies/Dependencies-1.3.0-dev

Getting the Slic3r source

The best way for getting the source is to install git so that you can stay up-to-date easily.

Installing Git for Windows

You can install Git by downloading this package:

If asked, choose to run git from Windows prompt (adjust path environment) instead of git Bash. Line ending conversions don't matter, choose the default.

There are also several alternatives:

  • GitHub for Windows Simplified and GUI tools developed by GitHub team.
  • TortoiseGit GUI with shell integration. UI inspired by TortoiseSvn.
  • Msysgit. The port of the original Git library, provides command prompt and API. The GUI ports listed above actually depends and includes a copy of msysgit.

Cloning the source

Open a command prompt and move to the directory where you want to create a Slic3r working copy. Then issue this command: git clone git://github.com/alexrj/Slic3r.git or git clone http://github.com/alexrj/Slic3r.git It will create a Slic3r directory in the current position. Issue git checkout master to get the latest source.

Note: the custom perl package seems to not have cpanm. at the moment of executing the git clone git://github.com/alexrj/Slic3r.git you will get a message about that; follow the instructions to install cpanminus and continue again.

Building Slic3r

  • After getting the sources, you will have a slic3r folder created, inside this floder extract the content of prebuilt dependency using 7-Zip or PeaZip.

Continue with next step. Dont try to build the GUI without this dependencies, it wont work

  • First, verify your Perl command environment is working. Start the prompt as stated above, then type perl -v. You should get some meaningful message. Check your perl installation if not.
  • Now cd to the folder where Slic3r source code is cloned, and proceed with the build process to verify the dependence installed:
cd Slic3r
perl Build.PL
perl Build.PL --gui

If you want to have a simple exe file to run Slic3r from (instead of invoking perl), open a Powershell window and cd to package/win and run & .\compile_wrapper.ps1 524. This will put 3 exe files in the same directory; either copy these files to the root Slic3r directory and/or run & .\package_win32.ps1 to make a zip file (similar to how our build server works). The former approach is fine if you aren't going to distribute Slic3r to machines that don't have slic3r-perl installed.

Compiling Slic3r (CLI Only, Limited) - No Perl (MinGW)

  1. Download CMake from https://cmake.org
  2. Ensure that CMake is in your PATH.
  3. Make a new directory in Slic3r root dir called "build".
  4. Cd to that directory.
  5. Setup for cmake
    • cmake ../src -D Boost_INCLUDE_DIR=C:\dev\boost_1_63_0
    • CMake doesn't always pick the correct generators and paths. Add -G "MinGW Makefiles" if you are using Slic3r Perl GCC tools (or another MinGW install). cmake --help gives the list of available generators.
  6. Run the makefile.
    • MinGW: mingw32-make.exe

Starting Slic3r

If you got the dependencies installed, now you could fire up the Slic3r with still in the command prompt by:

perl slic3r.pl

To start slic3r with a single click You should create a shortcut with a target that shows to the full path of the "wperl.exe" file and then the full path to Your "slicer.pl" file. For example, C:\dev\CitrusPerl\bin\wperl.exe C:\Users\YourUsername\Documents\GitHub\Slic3r\slic3r.pl

Happy Slicing!

Staying up-to-date

You just need a couple commands to keep your Slic3r copy up-to-date:

git pull
perl Build.PL

FAQ

  • Got "Can't write to cpanm home '/.cpanm' You should fix it with chown/chmod first." while issuing cpanm commands.

    You have to Shift-Right-click on the C: drive and click "Open Command Window Here" from the drop down list. Then in the command window type "mkdir .cpanm". You can close the command window and continue the install.

Building with Visual Studio 2013

Compiling Slic3r under Windows 10 64bit & Visual Studio 2013

Written by Voljtech @bubnikv Lightly edited and adapted to Markdown by Joseph Lenox @lordofhyphens

  1. Download the perl sources and extract the archive.

  2. Read perl-5.24.0\README.win32 for description of the installation process.

  3. Edit perl-5.24.0\win32\Makefile

    • Change the installation dir. I recommend to use 8 characters only directory names as some modules don't work with full path names on Windows.
    • A good naming convention is wperl for Win32 native build and sperl for Strawberry mingw build.
      wperl32d for 32bit debug build, wperl32r for 32bit release build, wperl64d for 64bit debug build etc.
    INST_DRV	= c:
    INST_TOP	= $(INST_DRV)\wperl64d
    
    • Select the compiler type:
    CCTYPE		= MSVC120FREE
    
    • Disable registry configuration:
    USE_NO_REGISTRY = define
    
    • If you want to debug Slic3r including the Perl interpreter (for example to troubleshoot crashes in the perl worker threads), set
    CFG = DebugSymbols
    

    to enable debugging symbols and disable optimization, but to still link against the release runtime libraries.

    The DebugSymbols settings selects the following set of compile switches for perl compilation:

    CL = -c -nologo -GF -W3 -Od -MD -Zi -fp:precise -DWIN32 -D_CONSOLE -DNO_STRICT -DWIN64 -DCONSERVATIVE -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DPERLDLL -DPERL_CORE
    

    (-GF enables string pooling, -W3 warning level, -MD links MSVCRT.lib, -Zi generates debug info, -fp:precise floating point precision) LINK = -nodefaultlib -debug -libpath:"c:\wperl64d\lib\CORE" -machine:AMD64 -subsystem:console,"5.02"

  4. Run the compilation, tests and install
    Open VS2013 x64 Native Tools Command Prompt
    which executes
    "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64
    in the command line.

    cd win32
    nmake
    nmake tests
    nmake install
    

    Tests will take forever to finis and a couple of tests will fail, namely the file access time, see the README.win32.
    Installation including the symbol files takes 114 MB on the disk.

  5. Create the startup scripts to run Perl & VC
    It is convenient to create a startup script to set the environment for the perl & visual studio compiler suite to run. Content of c:\wperl64d\cmdline_init.bat will be:

    set PATH=%PATH%;c:\wperl64d\site\bin;c:\wperl64d\bin
    set PERL_CPANM_HOME=c:\wperl64d\cpanm
    "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64
    

    It is also convient to create a windows shortcut to open a command line with the environment initialized:

    %comspec% /k ""c:\wperl64d\cmdline_init.bat""
    
  6. Setup cpan / cpanm
    When starting cpan from the command line for the first line, cpan will ask some questions and then create a user specific configuration file
    c:\Users\youruser.cpan\CPAN\MyConfig.pm

    I recommend to move the file to a global place, so you could then switch between perl installations and always have the proper CPAN working.
    c:\wperl64d\lib\CPAN\Config.pm

    I recommend to point the paths of the tools bzip2, gpg, gzip, patch, tar, unzip and wget to the cygwin64 installation directory and to install these cygwin packages.

    I also recommend to point the cpan working directories cpan_home, build_dir, histfile, keep_sources_where and prefs_dir to the perl installation directory, so one may switch safely between perl installations.
    install cpanminus by running

    cpan App::cpanminus
    
  7. Installing the nop-GUI perl modules by Slic3r

    git clone git://github.com/alexrj/Slic3r
    cd Slic3r
    perl Build.PL
    

    Math-Libm fails, because the Perl installation does not contain a working SSL module. Download it manually
    https://github.com/alexrj/Math-Libm
    and run

    perl Makefile.PL
    nmake
    nmake install
    

    IO-stringy-2.111 fails all test cases of t\IO_InnerFile.t
    Hopefully this does not hurt Slic3r. Go to the directory where cpanm unpacked the sources and run

    nmake install
    

    XML::SAX::ExpatXS fails, but Slic3r will run without it.

    Slic3r will not compile, because we did not configure boost library yet.

  8. Installing the GUI perl modules by Slic3r
    First let the Slic3r install what it could. Some modules will fail to install automatically.

    cd Slic3r
    perl Makefile.PL --gui
    

    We want to use the latest wxWidgets 3.0.3 beta, because it contains patches allowing us to enable multi sample anti aliasing in Slic3r 3D view. Get it here:
    https://github.com/discnl/wxWidgets/releases
    To disable optimization for more meaningfull debugging, set the environment variable CL=/Od
    By default, wxWidgets are compiled with the debugging information, without link time optimization.

    cd wxWidgets-3.0.3-beta1\build\msw
    nmake -f makefile.vc SHARED=1 BUILD=release
    

    Now it is a good time to set the WXDIR path, ideally to c:\wperl64d\cmdline_init.bat and restart the command line.
    set WXDIR=yoursourcesdir\wxWidgets-3.0.3-beta1

    Alien-wxWidgets-0.67
    Download this particular version (0.67) from
    http://search.cpan.org/~mdootson/Alien-wxWidgets-0.67/lib/Alien/wxWidgets.pm

    perl Build.PL --wxWidgets-unicode=1 --wxWidgets-build=0
    perl Build
    cpan install Alien
    cpan install Test::Pod
    cpan install Test::Pod::Coverage
    perl Build test
    perl Build install
    

    freeglut-2.8.1
    https://sourceforge.net/projects/freeglut/
    Dont't use freeglut-3.0.0, it will not work with perl OpenGL module!
    open freeglut-2.8.1\VisualStudio\2012\freeglut.sln
    let it upgrade the solution and all projects to Visual Studio 2013,
    and build release_static, x64, but disable the /GL switch (link time optimization)
    close the visual studio.

    OpenGL-0.6704
    http://search.cpan.org/~chm/OpenGL-0.6704_03/
    extract OpenGL-0.6704.tar.gz
    apply OpenGL-0.6704-Win64.patch
    copy freeglut-2.8.1\include\GL*.h to OpenGL-0.6704\include\GL
    copy freeglut-2.8.1\lib\x64\freeglut_static.lib OpenGL-0.6704\FreeGLUT\freeglut.lib

    set CL=/DFREEGLUT_STATIC /DNDEBUG /MD /DNO_STRICT
    set LIB=%LIB%;d:\src-perl\freeglut-2.8.1\lib\x64
    perl Makefile.PL verbose interface=FREEGLUT 
    nmake
    nmake test
    nmake install
    

    Wx-0.9928
    extract Wx-0.9928.tar.gz
    apply Wx-0.9928-Win64.patch

    set CL=-DNDEBUG
    perl Makefile.PL --wx-unicode --wx-toolkit=msw --extra-cflags="-DNDEBUG -fp:precise -DWIN32 -D_CONSOLE -DNO_STRICT -DWIN64 -DCONSERVATIVE -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS"
    

    Edit the generated Makefile: Replace slashes in paths with backslashes.
    following script does the work for you:

    d:\cygwin64\bin\sed.exe -i -e "s/\/c \/nologo \/TP \/MD \/Zi \/O2 \/W4 \/GR \/EHsc/-c -nologo -TP -MD -Zi -O2 -W4 -GR -EHsc/g;s/\//\\\/g" Makefile
    nmake
    nmake test
    nmake install
    

    To run the wxdemo, install

    cpan install Wx::Demo
    

    and start

    wxperl_demo
    

    Wx-GLCanvas-0.09
    http://search.cpan.org/~mbarbon/Wx-GLCanvas-0.09/lib/Wx/GLCanvas.pm
    unpack Wx-GLCanvas-0.09.tar.gz
    apply Wx-GLCanvas-0.09-wx3.0.3-MSA.patch
    apply Wx-GLCanvas-0.09-Win64.patch

    perl Makefile.PL
    nmake
    nmake test
    nmake install
    
  9. Patch WithXSpp.pm
    This is a workaround for Bug #129035 for perl5: XS compiler generates C #line comments for INCLUDE_COMMAND that Visual Studio compiler does not understand.

    Edit
    C:\wperl64d\site\lib\Module\Build\WithXSpp.pm

    replace
      $typemap_args .= '-t "' . _naive_shell_escape(Cwd::abs_path($_)) . '" ' foreach keys %$xspt_files;
    with following line. Note the removed quotes.
      $typemap_args .= '-t ' . _naive_shell_escape(Cwd::abs_path($_)) . ' ' foreach keys %$xspt_files;
    
    Similarly, replace
      my $cmd = qq{INCLUDE_COMMAND: \$^X -MExtUtils::XSpp::Cmd -e xspp -- $typemap_args "$full_path_file"\n\n};
    with the following line, again the inner quotes are removed.
      my $cmd = qq{INCLUDE_COMMAND: \$^X -MExtUtils::XSpp::Cmd -e xspp -- $typemap_args $full_path_file\n\n};
    
  10. Install boost
    Download the source code from http://www.boost.org/

    bootstrap.bat
    b2 toolset=msvc-12.0 address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/x64
    

    or

    b2 toolset=msvc-12.0 address-model=32 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/win32
    

    Then it is handy to add the following lines to c:\wperl64d\cmdline_init.bat

    set BOOST_DIR=D:\src-perl\boost_1_61_0
    set BOOST_INCLUDEDIR=%BOOST_DIR%\
    set BOOST_LIBRARYDIR=%BOOST_DIR%\stage\x64\lib
    

XSGUI Notes

wxWidgets - From Source

  • You need a copy of wx/setup.h in the general wxwidgets include dir. If building the library dlls, this will end up in WXDIR/lib/gcc_dll/mswu/wx. Copy everything in this dir to WXDIR/include.
  • Quickie wxWidgets build instructions (Assumes that gcc, g++, etc from slic3r-perl is in your PATH).
    • Extract or clone archive of wxwidgets 3.1.0 to WXWIN
    • cd WXWIN\build\msw
    • Run: mingw32-make.exe -f .\makefile.gcc SHARED=1 UNICODE=1 BUILD=release

Building with CMake and MS Visual Studio 2017 Community Edition

Note: The CMake/cppgui build is incomplete. As of writing, support generation does not work and the GUI does not function.

CLI Build

  1. Download Visual Studio 2017 Community Edition
  2. Ensure that it is updated to 15.7.6
  3. Build boost or download the binaries from Sourceforge and put them into the correct path (as shown below)
  4. Update slic3r checkout
  5. mkdir build
  6. cmake ../src -DBOOST_ROOT=C:\dev\boost_1_67_0 -DSLIC3R_BUILD_TESTS=OFF -DSLIC3R_STATIC=ON -DBOOST_LIBRARYDIR=C:\dev\boost_1_67_0\stage\lib -G"Visual Studio 15 2017 Win64"
    • if you downloaded the binary exe instead of building, replace C:\dev\boost_1_67_0 with the path to where you put boost and and the librarydir to wherever the libraries (dlls and lib files) ended up.
  7. cmake --build . -- /M:4
    • This builds slic3r and libslic3r using MSBuild and uses 4 cores.
  8. You now have libslic3r built

Building Boost with MSVC 2017

  1. Download Boost 1.67.0 from boost.org
  2. Extract to C:\dev
  3. Copy/paste the following into a batch file build_boost.bat
  4. Run batch file.
rem Visual Studio 2017 -> set msvcver=msvc-14.1
 
set msvcver=msvc-14.1
 
rem Start building boost
echo Building %boost_dir% with %cores% cores using toolset %msvcver%.
 
cd %boost_dir%
call bootstrap.bat
 
rem Most libraries can be static libs
b2 -j%cores% toolset=%msvcver% address-model=64 architecture=x86 link=static threading=multi runtime-link=static
rem b2 -j%cores% toolset=%msvcver% address-model=32 architecture=x86 link=static threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/win32
b2 -j%cores% toolset=%msvcver% address-model=64 architecture=x86 link=shared threading=multi runtime-link=shared
rem --build-type=minimal stage --stagedir=stage/x64 
rem b2 -j%cores% toolset=%msvcver% address-model=32 architecture=x86 link=shared threading=multi runtime-link=shared --build-type=minimal stage --stagedir=stage/win32
 
pause

Notes for Visual Studio 2019

CMake 3.16 is required to build as a VS2019 project

Notes for wxWidgets and building Slic3r

First, build or download binaries for wxWidgets and install to a target directory.

If you are building wxWidgets with Visual Studio generator from the command line, you need to specify --config Release at the build step (cmake --build . --config Release) to be able to use cmake --install .

Then, include the following switches when building with CMake:

-DwxWidgets_LIB_DIR=/path/to/wxwidgets/lib/lib_type -DwxWidgets_ROOT_DIR=/path/to/wxwidgets

where /path/to/wxwidgets is where you installed wxWidgets (if building from source, this defaults to C:\Program Files\wxWidgets)