Skip to content

Running Slic3r from git on OS X

Alessandro Ranellucci edited this page Jul 21, 2021 · 47 revisions

This page contains instructions on how to run the latest Slic3r from git on Apple OS X. The instructions have been verified to work on OS X Lion (10.7) and OS X Mountain Lion (10.8). Please notice that following these instructions are not needed for running the binary releases of Slic3r for OS X available from slic3r.org or the automated builds available from dl.slic3r.org/dev.

Installing the necessary command line development tools

There are two ways to install the necessary command line tools (git, cc, ...) for installing Slic3r and its dependencies on OS X. Both require creating a free Apple ID. The following instructions might be slightly outdated but you'll find instructions and tutorials on the web.

Installing Xcode + Command Line Tools

One option is to install the full, graphical Xcode IDE (version 4.3 or later), which includes an option to install the necessary command line tools:

  • Download and install Xcode from the Mac App Store
  • Launch Xcode.app
  • Open Preferences and install the Command Line Tools from the Downloads tab

Installing the stand-alone Command Line Tools

Another option is to install the stand-alone Command Line Tools for Xcode:

Installing everything via homebrew

Homebrew is the preferred way on newer builds. It will pull down Command Line Tools for Xcode as well and otherwise cover everything you need.

  1. On Mojave, install Homebrew
  2. Install dependencies for Slic3r.
brew install boost gcc wxwidgets perl cpanminus cmake wxmac@3.0
  1. Continue on to building Slic3r.

Installing Perl (via Perlbrew)

Another option is to use perlbrew, which install a custom perl instance in your userland space.

  • Install perlbrew: curl -L https://install.perlbrew.pl | bash
    • Copy the source statement given to you by perlbrew's output to your ~/.bash_profile
    • Close and reopen the terminal.
  • Compile perl
    • OSX 10.12 (MacOS Sierra)
      • Use this command line: PERLBREW_CONFIGURE_FLAGS='-de -Dccflags="-mmacosx-version-min=10.12 -fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector" -Dccdlflags="-mmacosx-version-min=10.12" -Dldflags="-mmacosx-version-min=10.12 -fstack-protector" -Dlddlflags="-mmacosx-version-min=10.12 -bundle -undefined dynamic_lookup -fstack-protector"' perlbrew install perl-blead --thread --64all -j 2 --as threaded-perl-blead --force
      • Switch to the built perl: perlbrew switch threaded-perl-blead
    • OSX 10.7-10.11
      • Use this command line: perlbrew install perl-5.24.1 -Dusethreads -Duselargefiles -Dcccdlflags=-fPIC -Doptimize=-O2 --as threaded-perl-5.24.1
      • Switch to the built perl: perlbrew switch threaded-perl-5.24.1
  • Install cpanm: perlbrew install-cpanm

Install Boost (manual compilation)

As an alternative you can build it manually:

  • Download the latest Boost (1_64?) from http://www.boost.org/users/download/
  • Extract somewhere (e.g. in ~/boost_1_64_0).
    • cd ~/boost_1_64_0
    • ./bootstrap.sh
    • ./b2 link=static runtime-link=static variant=release
  • Wait.
  • In the next step, you'll have to use BOOST_DIR=~/boost_1_64_0

Building Slic3r

  • Run the following instructions:
    git clone git://github.com/slic3r/Slic3r
    cd Slic3r
    BOOST_DIR=/usr/local SLIC3R_STATIC=1 perl Build.PL
    perl Build.PL --gui
  • Note: You may omit the reference to BOOST_DIR if everything was installed from Homebrew.
  • (Optional) Archive a copy of the local-lib directory to avoid having to rebuild Slic3r dependencies if the Slic3r directory gets deleted.
  • Note: You may need to run perl Build.PL --gui a couple times if the SSL module from cpan fails to install due to a timeout (see install logs).
  • Build instruction for Boost installed w MacPorts:
SLIC3R_STATIC=1 BOOST_INCLUDEPATH=/opt/local/include BOOST_LIBRARYPATH=/opt/local/lib perl Build.PL

And a workaround, in case the (MacPorts) Boost dynamic libraries are not found in the link step:

vi xs/Build.PL
...
168     # Either static linking, or check_lib could not be used to find the boost libraries.$
169     my $lib_prefix = 'libboost_';$
170     #my $lib_ext = $Config{lib_ext};$
171     my $lib_ext = '.dylib';$
:wq

(Old instructions)

OSX 10.9 Maverick

  • Newer versions of OS X (Maverick) have perl 5.16 as default with which Slic3r is not supported. The default can be changed with: defaults write com.apple.versioner.perl Version 5.12
  • Command Line Tools can be installed with: xcode-select --install

OSX 10.11 El Capitan

Your build may fail in the last step (building GUI) on El Capitan with message similar to this:

Building and testing Alien-wxWidgets-0.67 ... FAIL
! Installing Alien::wxWidgets failed. See /Users/yourname/.cpanm/work/1464795363.4904/build.log for details.
Retry with --force to force install it.

That means you should install wxMac first by running:

brew install wxmac@3.0

Installing the Boost libraries

If you have homebrew installed, use brew install boost --universal. Otherwise you can use MacPorts or any other method you know.

Installing Slic3r dependencies as root

To instead install the Slic3r dependencies as root, execute the following steps:

git clone git://github.com/slic3r/Slic3r
cd Slic3r
sudo cpan local::lib
perl Build.PL
perl Build.PL --gui

Updating locally installed modules

An easy way to update only your locally installed modules is to parse the output of perldoc perllocal and pass the names of the locally installed modules to cpanm -i:

perldoc -t perllocal | grep Module | sed -e 's/^.* "Module" //' -e 's/-/::/g' | sort | uniq | xargs cpanm -i

Troubleshooting

  • If you have installed perl via MacPorts and the build fails, try using the original OS X version of perl (/usr/bin/perl).
  • If the build still fails, install the dependencies manually. This should fix issues with newer OS X versions.
  • Consider using perlbrew https://perlbrew.pl/

Build Slic3r (C++)

Note: Slic3r's C++ side only supports CLI. While a GUI may be built, it is nonfunctional.

Prerequisites

  • Slic3r's C++ toolpath requires CMake 3.9 or higher.
  • Boost is still required.
  • The GUI code requires a C++14 compliant compiler (gcc-6 or clang 3.4)

On a recent macOS, just do brew install cmake boost wxWidgets.

Procedure

mkdir build
cd build
cmake ../src 
cmake --build . -- -j4 

There are several command switches that may be passed to cmake. For example, this build the (still incomplete) GUI:

cmake ../src -DEnable_GUI=1

Use cmake ../src -LH in the build directory to display all the available switches.



Clone this wiki locally