Skip to content

Latest commit

 

History

History
216 lines (146 loc) · 11.5 KB

How to build - Windows.md

File metadata and controls

216 lines (146 loc) · 11.5 KB

Step by Step Visual Studio 2019 Instructions

Install the tools

Install Visual Studio Community 2019 from visualstudio.microsoft.com/vs/. Older versions are not supported as PrusaSlicer requires support for C++17. Select all workload options for C++ and make sure to launch Visual Studio after install (to ensure that the full setup completes).

Install git for Windows from gitforwindows.org Download and run the exe accepting all defaults

Download sources

Clone the respository. To place it in C:\src\PrusaSlicer, run:

c:> mkdir src
c:> cd src
c:\src> git clone https://github.com/prusa3d/PrusaSlicer.git

Run the automatic build script

The script build_win.bat will automatically find the default Visual Studio installation, set up the build environment, and then run both CMake and MSBuild to generate the dependencies and application as needed. If you'd rather do these steps manually, you can skip to the Manual Build Instructions in the next section. Otherwise, just run the following command to get everything going with the default configs:

c:\src>cd c:\src\PrusaSlicer
c:\src\PrusaSlicer>build_win.bat -d=..\PrusaSlicer-deps -r=console

The build script will run for a while (over an hour, depending on your machine) and automatically perform the following steps:

  1. Configure and build deps as RelWithDebInfo with c:\src\PrusaSlicer-deps as the destination directory
  2. Configure and build all application targets as RelWithDebInfo
  3. Launch the resulting prusa-slicer-console.exe binary

You can change the above command line options to do things like:

  • Change the destination for the dependencies by pointing -d to a different directory such as: build_win.bat -d=s:\PrusaSlicerDeps
  • Open the solution in Visual Studio after the build completes by changing the -r switch to -r=ide
  • Generate a release build without debug info by adding -c=Release or a full debug build with -c=Debug
  • Perform an incremental application build (the default) with: build_win.bat -s=app-dirty
  • Clean and rebuild the application: build_win.bat -s=app
  • Clean and rebuild the dependencies: build_win.bat -s=deps
  • Clean and rebuild everything (app and deps): build_win.bat -s=all
  • The full list of build script options can be listed by running: build_win.bat -?

Troubleshooting

You're best off initiating builds from within Visual Studio for day-to-day development. However, the build_win.bat script can be very helpful if you run into build failures after updating your source tree. Here are some tips to keep in mind:

  • The last several lines of output from build_win.bat will usually have the most helpful error messages.
  • If CMake complains about missing binaries or paths (e.g. after updating Visual Studio), building with build_win.bat will force CMake to regenerate its cache on an error.
  • After a deps change, you may just need to rebuild everything with the -s=all switch.
  • Reading through the instructions in the next section may help diagnose more complex issues.

Manual Build Instructions

Follow the steps below if you want to understand how to perform a manual build, or if you're troubleshooting issues with the automatic build script.

Compile the dependencies.

Dependencies are updated seldomly, thus they are compiled out of the PrusaSlicer source tree. Go to the Windows Start Menu and Click on "Visual Studio 2019" folder, then select the ->"x64 Native Tools Command Prompt" to open a command window and run the following:

cd c:\src\PrusaSlicer\deps
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -DDESTDIR="c:\src\PrusaSlicer-deps"

msbuild /m ALL_BUILD.vcxproj // This took 13.5 minutes on my machine: core I7-7700K @ 4.2Ghz with 32GB main memory and 20min on a average laptop

Generate Visual Studio project file for PrusaSlicer, referencing the precompiled dependencies.

Go to the Windows Start Menu and Click on "Visual Studio 2019" folder, then select the ->"x64 Native Tools Command Prompt" to open a command window and run the following:

cd c:\src\PrusaSlicer\
mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -DCMAKE_PREFIX_PATH="c:\src\PrusaSlicer-deps\usr\local"

Note that CMAKE_PREFIX_PATH must be absolute path. A relative path like "....\PrusaSlicer-deps\usr\local" does not work.

Compile PrusaSlicer.

Double-click c:\src\PrusaSlicer\build\PrusaSlicer.sln to open in Visual Studio 2019. OR Open Visual Studio for C++ development (VS asks this the first time you start it).

Select PrusaSlicer_app_gui as your startup project (right-click->Set as Startup Project).

Run Build->Rebuild Solution once to populate all required dependency modules. This is NOT done automatically when you build/run. If you run both Debug and Release variants, you will need to do this once for each.

Debug->Start Debugging or press F5

PrusaSlicer should start. You're up and running!

note: Thanks to @douggorgen for the original guide, as an answer for a issue

The below information is out of date, but still useful for reference purposes

We have switched to MS Visual Studio 2019.

We don't use MSVS 2013 any more. At the moment we are in the process of creating new pre-built dependency bundles and updating this document. In the meantime, you will need to compile the dependencies yourself the same way as before except with CMake generators for MSVS 2019 instead of 2013.

Thank you for understanding.


Building PrusaSlicer on Microsoft Windows

The currently supported way of building PrusaSlicer on Windows is with CMake and MS Visual Studio 2013. You can use the free Visual Studio 2013 Community Edition. CMake installer can be downloaded from the official website.

Building with newer versions of MSVS (2015, 2017) may work too as reported by some of our users.

Note: Thanks to @supermerill for testing and inspiration for this guide.

Dependencies

On Windows PrusaSlicer is built against statically built libraries. We provide a prebuilt package of all the needed dependencies. This package only works on Visual Studio 2013, so if you are using a newer version of Visual Studio, you need to compile the dependencies yourself as per below. The package comes in a several variants:

  • 64 bit, Release mode only (41 MB, 578 MB unpacked)
  • 64 bit, Release and Debug mode (88 MB, 1.3 GB unpacked)
  • 32 bit, Release mode only (38 MB, 520 MB unpacked)
  • 32 bit, Release and Debug mode (74 MB, 1.1 GB unpacked)

When unsure, use the Release mode only variant, the Release and Debug variant is only needed for debugging & development.

If you're unsure where to unpack the package, unpack it into C:\local\ (but it can really be anywhere).

Alternatively you can also compile the dependencies yourself, see below.

Building PrusaSlicer with Visual Studio

First obtain the PrusaSlicer sources via either git or by extracting the source archive.

Then you will need to note down the so-called 'prefix path' to the dependencies, this is the location of the dependencies packages + \usr\local appended. For example on 64 bits this would be C:\local\destdir-64\usr\local. The prefix path will need to be passed to CMake.

When ready, open the relevant Visual Studio command line and cd into the directory with PrusaSlicer sources. Use these commands to prepare Visual Studio solution file:

mkdir build
cd build
cmake .. -G "Visual Studio 12 Win64" -DCMAKE_PREFIX_PATH="<insert prefix path here>"

Note that if you're building a 32-bit variant, you will need to change the "Visual Studio 12 Win64" to just "Visual Studio 12".

Conversely, if you're using Visual Studio version other than 2013, the version number will need to be changed accordingly.

If cmake has finished without errors, go to the build directory and open the PrusaSlicer.sln solution file in Visual Studio. Before building, make sure you're building the right project (use one of those starting with PrusaSlicer_app_...) and that you're building with the right configuration, i.e. Release vs. Debug. When unsure, choose Release. Note that you won't be able to build a Debug variant against a Release-only dependencies package.

Installing using the INSTALL project

PrusaSlicer can be run from the Visual Studio or from Visual Studio's build directory (src\Release or src\Debug), but for longer-term usage you might want to install somewhere using the INSTALL project. By default, this installs into C:\Program Files\PrusaSlicer. To customize the install path, use the -DCMAKE_INSTALL_PREFIX=<path of your choice> when invoking cmake.

Building from the command line

There are several options for building from the command line:

To build with msbuild, use the same CMake command as in previous paragraph and then build using

msbuild /m /P:Configuration=Release ALL_BUILD.vcxproj

To build with Ninja or nmake, replace the -G option in the CMake call with -G Ninja or -G "NMake Makefiles" , respectively. Then use either ninja or nmake to start the build.

To install, use msbuild /P:Configuration=Release INSTALL.vcxproj , ninja install , or nmake install .

Building the dependencies package yourself

The dependencies package is built using CMake scripts inside the deps subdirectory of PrusaSlicer sources. (This is intentionally not interconnected with the CMake scripts in the rest of the sources.)

Open the preferred Visual Studio command line (64 or 32 bit variant) and cd into the directory with PrusaSlicer sources. Then cd into the deps directory and use these commands to build:

mkdir build
cd build
cmake .. -G "Visual Studio 16 2019" -DDESTDIR="C:\local\destdir-custom"
msbuild /m ALL_BUILD.vcxproj

You can also use the Visual Studio GUI or other generators as mentioned above.

The DESTDIR option is the location where the bundle will be installed. This may be customized. If you leave it empty, the DESTDIR will be placed inside the same build directory.

Warning: If the build directory is nested too deep inside other folders, various file paths during the build become too long and the build might fail due to file writing errors (*). For this reason, it is recommended to place the build directory relatively close to the drive root.

Note that the build variant that you may choose using Visual Studio (i.e. Release or Debug etc.) when building the dependency package is not relevant. The dependency build will by default build both the Release and Debug variants regardless of what you choose in Visual Studio. You can disable building of the debug variant by passing the

-DDEP_DEBUG=OFF

option to CMake, this will only produce a Release build.

Refer to the CMake scripts inside the deps directory to see which dependencies are built in what versions and how this is done.

*) Specifically, the problem arises when building boost. Boost build tool appends all build options into paths of intermediate files, which are not handled correctly by either b2.exe or possibly ninja (?).