Skip to content

Commit f0e3acd

Browse files
authored
Add readme/instructions for MSVC based builds (openscad#6140)
1 parent 3a36cb1 commit f0e3acd

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ OpenSCAD for Windows is usually cross-compiled from Linux. If you wish to
225225
attempt an MSVC build on Windows, please see this site:
226226
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Building_on_Windows
227227

228+
MSVC build support has been added to OpenSCAD. For instructions on how to build it,
229+
refer to [building with MSVC](doc/win-build.md).
230+
228231
To cross-build, first make sure that you have all necessary dependencies
229232
of the MXE project ( listed at https://mxe.cc/#requirements ). Don't install
230233
MXE itself, the scripts below will do that for you under `$HOME/openscad_deps/mxe`

doc/win-build.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Build using Visual Studio and vcpkg
2+
3+
Follow these steps to build OpenSCAD with Microsoft Visual Studio:
4+
5+
- Make sure you have git installed and in your PATH. For installing Git, follow the
6+
instructions [here](https://github.com/git-guides/install-git).
7+
To add a variable to PATH, a tutorial is available [here](https://www.eukhost.com/kb/how-to-add-to-the-path-on-windows-10-and-windows-11/)
8+
- Install Visual Studio 2022. Check the 'Desktop development with C++' component
9+
in the VS installer.
10+
- Download WinFlexBison binaries from the project's Github page:
11+
https://github.com/lexxmark/winflexbison. Unzip it somewhere convenient and
12+
add that location to your PATH.
13+
- Install vcpkg in a convenient location with a short path (this is important),
14+
e.g. c:\vcpkg or d:\vcpkg. Instructions are at
15+
https://vcpkg.io/en/getting-started but an even shorter version is to do:
16+
17+
```
18+
cd d:\vcpkg
19+
git clone https://github.com/Microsoft/vcpkg.git
20+
.\vcpkg\bootstrap-vcpkg.bat
21+
```
22+
- Then add d:\vcpkg to your PATH.
23+
Clone the OpenSCAD repo somewhere (in this example, d:\openscad) and run
24+
scripts\win-msvc-build.bat in it:
25+
26+
```
27+
git clone https://github.com/openscad/openscad.git
28+
cd openscad
29+
scripts\win-msvc-build.bat
30+
```
31+
32+
What that batch file does is first install all required packages through vcpkg,
33+
then generate Visual Studio project files in the 'build' directory and finally
34+
builds Release and Debug versions. Results will be in build\Debug and
35+
build\Release.
36+
37+
If you encounter issues installing vcpkg packages, a solution is manually installing via `vcpkg install dep:x64-windows`, and disabling manifest mode installation. A helpful command for doing this can be found in `scripts/win-msvc-build.bat`
38+
39+
For building OpenSCAD with GUI mode on (Work in Progress), a [branch](https://github.com/Sparsh-N/openscad/tree/msvc-gui) can be used. For this, you would need Qt and QScintilla installed and compiled from source, not vcpkg.

scripts/win-msvc-build.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mkdir build
77
rem Change the option CMAKE_TOOLCHAIN_FILE to your installation. Below are 2 initial ways to build.
88
rem 1) Headless Build
99
cmake -B build -S . -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake -DHEADLESS=ON -DUSE_BUILTIN_OPENCSG=TRUE -DCMAKE_EXE_LINKER_FLAGS="/manifest:no" -DCMAKE_MODULE_LINKER_FLAGS="/manifest:no" -DCMAKE_SHARED_LINKER_FLAGS="/manifest:no" -DTBB_DIR=D:/vcpkg/installed/x64-windows/share/tbb
10-
rem 2) GUI Build (Needs Qt Installed from Source, not vcpkg)
10+
rem 2) GUI Build (Needs Qt and QScintilla Installed from Source, not vcpkg)
1111
rem cmake -B build -S . -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake -DUSE_BUILTIN_OPENCSG=TRUE -DUSE_QT6=ON -DCMAKE_EXE_LINKER_FLAGS="/manifest:no" -DCMAKE_MODULE_LINKER_FLAGS="/manifest:no" -DCMAKE_SHARED_LINKER_FLAGS="/manifest:no" -DTBB_DIR=D:/vcpkg/installed/x64-windows/share/tbb -Dunofficial-qscintilla_DIR="D:/vcpkg/installed/x64-windows/share/unofficial-qscintilla"
1212

1313
rem Second step of build process, each build should take ~30 mins for a Headless build.

0 commit comments

Comments
 (0)