OpenSCAD User Manual/Building on Microsoft Windows
Set up tools and dependencies
[edit | edit source]Download 64-bit MSYS2.
- Note: 32-bit MSYS2 appears to no longer be available.
Install per instructions, including the install-time upgrades (pacman -Syu, -Su). Installing development components is not necessary at this point.
NOTE: Previous versions of these instructions used the MINGW64 environment, while this version uses the UCRT64 environment. There is no immediate need to switch existing build environments over, but it seems clear that UCRT64 is the preferred environment. To switch, it seems to be adequate to start the MSYS UCRT64 shell, install dependencies, and build OpenSCAD into a fresh build directory.
Install OpenSCAD build dependencies
[edit | edit source]Start an MSYS2 shell window using the "MSYS2 UCRT64" link in the Start menu.
$ curl -L https://github.com/openscad/openscad/raw/master/scripts/msys2-install-dependencies.sh | sh
Set up source directory
[edit | edit source]Start an MSYS2 shell window using the "MSYS2 UCRT64" link in the Start menu.
$ git clone https://github.com/openscad/openscad.git srcdir $ cd srcdir $ git submodule update --init --recursive
Replace "srcdir" with whatever name you like.
Build with command line
[edit | edit source]Set up build directory
[edit | edit source]Start an MSYS2 shell window using the "MSYS2 UCRT64" link in the Start menu.
$ cd srcdir $ mkdir builddir $ cd builddir $ cmake .. -G"MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DEXPERIMENTAL=ON -DSNAPSHOT=ON
Replace "builddir" with whatever name you like.
Build
[edit | edit source]Start an MSYS2 shell window using the "MSYS2 UCRT64" link in the Start menu.
$ cd srcdir/builddir $ cmake --build . $ cmake --install . --prefix=.
You might want to add -jN, where N is the number of compiles to run in parallel - approximately, the number of processor cores on the system.
Run
[edit | edit source]Start an MSYS2 shell window using the "MSYS2 UCRT64" link in the Start menu.
$ cd srcdir/builddir $ ./openscad
Build with Qt Creator IDE
[edit | edit source]Note: When I tried this, it mostly built but failed in cgalutils.cc, in an environment where the command-line build worked.
Install QT Creator
[edit | edit source]$ pacman -S mingw-w64-ucrt-x86_64-qt-creator
Load project
[edit | edit source]$ qtcreator &
Open CMakeLists.txt from the top of the source tree. Use the default configuration.
Build
[edit | edit source]Build with Control-B or Build / Build project "openscad".
Prebuilt OpenSCAD
[edit | edit source]Note that MSYS2 also provides a precompiled OpenSCAD package. This can be installed using
$ pacman -S mingw-w64-ucrt-x86_64-openscad
Historical Notes
[edit | edit source]The following is historical content from previous versions of this page, that might still be applicable. Caution: these historical notes are for the MINGW64 environment rather than the UCRT64 environment. There are UCRT64 equivalents of these components that should probably be used.
QtCreator
[edit | edit source]The Build-Type must be changed to "Release".
In some cases the build fails when generating the parser code using flex and bison. In that case disabling the "Shadow Build" (see Project tab / General Settings) can help.
Building Debug Version
[edit | edit source]Currently the QScintilla package provides only a release version of the library. Using this with a debug build of OpenSCAD is not possible (the resulting binary crashs with an assertion error inside Qt).
To create a working debug version of OpenSCAD, a debug version of QScintilla must be built manually.
- Download QScintilla source code from http://www.riverbankcomputing.com/software/qscintilla/download
- Extract the archive, change to the subfolder Qt4Qt5 in the QScintilla source tree and edit the qscintilla.pro project file. Rename the build target so the DLL gets a "d" suffix
- TARGET = qscintilla2 + TARGET = qscintilla2d
- Change the release config option to debug (also in qscintilla.pro)
- CONFIG += qt warn_off release thread exceptions + CONFIG += qt warn_off debug thread exceptions
- Build the debug DLL
$ qmake $ mingw32-make
- Copy the debug library into the default MSYS2 folders
$ cp debug/libqscintilla2d.dll.a /mingw64/lib/ $ cp debug/qscintilla2d.dll /mingw64/bin/
OpenGL (Optional)
[edit | edit source]OpenSCAD needs at least OpenGL version 2.0 to be able to correctly render the preview using OpenCSG. It's possible to run with older versions (e.g. the default provided by Windows, which is 1.4) but the display might differ from the expected output.
For systems that can't provide the needed OpenGL version (e.g. when running on a VM) it's still possible to get the a more recent OpenGL driver using the Mesa software renderer.
$ pacman -S mingw-w64-x86_64-mesa
After installing the mesa driver (default location is C:\msys64\mingw64\bin, the driver itself is opengl32.dll), it can be even activated by copying it into the same folder as the OpenSCAD.exe.
It's possible to enable it for the whole system by copying it to the Windows system32 folder, replacing the old system driver. (Warning: Do that only if you have a backup and enough knowledge how to restore files in a broken Windows installation!)