OpenSCAD User Manual/Building on Microsoft Windows

From Wikibooks, open books for an open world
Jump to: navigation, search

This page is currently under development - the goal is that it will describe how to set up a functional development environment for OpenSCAD on Windows.

Downloads[edit]

Download the "msys2 installer" matching your Windows system (32bit or 64bit). The following description follows the 64bit installation, so if you have a 32bit Windows, some of the package names need to be changed for the 32bit versions of the packages (usually that's i686 instead of x86_64).

Installation[edit]

MSYS2[edit]

Start by installing MYSYS2 following the documentation on the download page.

After installation a bash window will appear, all the following step will be done from inside this MSYS console window.

Install packages with needed dependencies and the QtCreator IDE:

$ pacman -Sy
$ pacman -S mingw-w64-x86_64-qt-creator
$ pacman -S mingw-w64-x86_64-gdb
$ pacman -S mingw-w64-x86_64-boost
$ pacman -S mingw-w64-x86_64-cgal
$ pacman -S mingw-w64-x86_64-eigen3
$ pacman -S mingw-w64-x86_64-glew
$ pacman -S mingw-w64-x86_64-qscintilla
$ pacman -S mingw-w64-x86_64-opencsg
$ pacman -S bison
$ pacman -S mingw-w64-x86_64-pkg-config
$ pacman -S git

or for those who have trouble copy and pasting:

$ pacman -Sy;
$ a="mingw-w64-x86_64-";  pacman -S ${a}qt-creator ${a}gdb ${a}boost ${a}cgal \
    ${a}eigen3 ${a}glew ${a}qscintilla ${a}opencsg bison ${a}pkg-config git   
                                                                                                                     

If you want to start the MSYS2 environment later, use the MinGW-32 (for 32bit Systems) or MinGW-64 links in the start menu to open the console window.

Note that MSYS2 also provides a precompiled OpenSCAD package. This can be installed using

$ pacman -S mingw-w64-x86_64-openscad

Updating MSYS2[edit]

Update the packages to the latest version in the MSYS2 repository, follow the steps in the MSYS2 wiki. It's important to update the core packages first.

OpenSCAD[edit]

Get the OpenSCAD sourcecode using GIT:

$ git clone git://github.com/openscad/openscad.git

Compiling[edit]

Modify .bashrc[edit]

For some reason msys2 has qmake install in /mingw64/bin ( cross compile issue maybe? ) which is not in the path. Grab a text editor such as nano and open .bashrc.

$ pacman -S nano
$ nano ~/.bashrc

Add the following line to the very end then save and exit.

$ export PATH=/mingw64/bin:$PATH

Note you can git a list of editor with:

$ pacman -Ss editor 

If you don't do this, you get 'command qmake not found' when you try to execute qmake as shown below.

Commandline[edit]

Currently it's not possible to use the debug build with the library provided by MSYS2 as linking release QScintilla and debug Qt will cause OpenSCAD to crash. See "Building Debug Version" for how to manually build a debug version of QScintilla.

Change to the folder the OpenSCAD repository is cloned to and run qmake to create the Makefiles and compile using make.

$ qmake openscad.pro CONFIG-=debug
$ mingw32-make.exe

The resource lookup does not yet work with the file layout created with that build. The easiest way is to move the compiled openscad.exe to the root folder of the OpenSCAD source code.

$ mv release/openscad.exe .

QtCreator[edit]

$ qtcreator &

To compile and run OpenSCAD, just open the main project file openscad.pro which is located in the top folder of the cloned github project.

The Build-Type must be changed to "Release".

Press Ctrl+B to build.

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]

Currently the QScintilla package only provides a release version of the library. Using this with a debug build of OpenSCAD is not possible (the resulting binary will crash with an assertion error inside Qt).

To create a working debug version of OpenSCAD, a debug version of QScintilla must be built manually.

  • 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 will get 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]

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: Only do that if you have a backup and enough knowledge how to restore files in a broken Windows installation!)