How to build and to debug gmsh and OpenCACADE in Visual Studio Community 2022
- Download and install Visual Studio Community 2022 (free) for Windows'10.
- Download OpenCascade Windows installer VC++ 2017 64 bit: opencascade-7.6.0-vc14-64.exe. Run it and install OpenCascade 7.6.0.
OpenCASCADE-7.6.0-vc14-64 directory contents:
ffmpeg-3.3.4-64
freeimage-3.17.0-vc14-64
freetype-2.5.5-vc14-64
opencascade-7.6.0
openvr-1.14.15-64
qt5.11.2-vc14-64
rapidjson-1.1.0
tbb_2017.0.100
tcltk-86-64
vtk-6.1.0-vc14-64
opencascade.ico
unins000.dat
unins000.exe
unins000.msg
We will use include headers and precompiled binaries to build gmsh.
If you want to recompile and to build OpenCascade in Visual Studio go to opencascade-7.6.0/adm/msvc solutions (see below).
3. Download FLTK. I used 1.4.x version.
To build FLTK we use cygwin (I am practically sure it could be done also in VS 2022).
Fisrt, start Development Command Prompt for VS2022 from Windows menu or from VS2022>Tools. In this terminal we go to cygwin64 and start Cygwin.bat. It provides us Visual Studio generator for cmake. The presence of cmake generators could be checked by cmake -G
. Our generator is Visual Studio 17 2022
. Next we goto FLTK directory:
mkdir build
cd build
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON ..
Now there is FLTK.sln in build directory and we use it for VS2022 to build libraries in Release mode.
Directory build/lib/Release:
fltk.lib
fltk_forms.lib
fltk_gl.lib
fltk_images.lib
fltk_jpeg.lib
fltk_png.lib
fltk_z.lib
-
Optionally, we could install freetype-2.11.1. Solution file is located in builds/windows/vs2010. It could be used for building static library - obj/freetype.lib.
Alternatively, we possibly could use precompiled freetype-2.5.5 from OpenCascade directory. -
Next, we download gmsh source code and use again cygwin to generate VS solution file.
cd gmsh
mkdir build
cd build
cmake -DENABLE_OPENMP=0 -DEXTERNAL_LIBRARIES=gdiplus.lib ..
To prepare most of packages for gmsh, we need to provide theirs headers and library visibility for cmake. I used usr/local directory for purpose.
Now build/gmsh.sln has to be used to build gmsh in VS. For gmsh project in solution disable macro OCC_CONVERT_SIGNALS change build subsystem from windows to console. Also, check again that all needed headers and libraries are included. And provide visibility of OpenCascade DLLs - include in PATH system variable or copy them to system directory or just copy them to the directory with built gmsh.exe.
Any comments and improvements are welcome.