Running Slic3r from git on Windows

Joseph Lenox edited this page Aug 30, 2016 · 38 revisions

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 faciliates 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 integrates itself into the Windows shell. Side by side installation of different versions would be difficult if not impossible.

At the time of writing we recommend Strawberry Perl 5.22 as it's the most up-to-date.

Strawberry Perl

  • Download a copy from http://strawberryperl.com/ Select version 5.22.
  • Install it, following the on screen instruction. 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.59.0. 1.61.0 changed things and thus the build instructions do not work for it.

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_59_0. Run the following instructions from the Perl command prompt

cd C:\dev\boost_1_59_0
bootstrap.bat mingw
b2 toolset=gcc link=static runtime-link=static variant=release

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 stable to switch to the stable branch (fewer changes).

Building Slic3r

  • 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

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"

  1. 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.

  1. 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""

  1. 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

  1. 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.

6) 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

7) 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};

8) 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