Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
gmsh
gmsh
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 124
    • Issues 124
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 6
    • Merge Requests 6
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • gmsh
  • gmshgmsh
  • Wiki
  • Gmsh compilation

Last edited by Christophe Geuzaine Oct 02, 2020
Page history

Gmsh compilation

General build instructions are available in the top-level README.

This page contains more detailed instructions to compile a full-featured version of Gmsh, including the compilation of common dependencies: OpenCASCADE and FLTK.

Note that the commands used for the continuous integration builds and for the official Gmsh binary releases are available in the .gitlab-ci.yml file. The Linux builds are performed in Docker containers. The Windows builds are done on virtual machines using the MingW compilers under Cygwin.

OpenCASCADE

OpenCASCADE is a free CAD kernel that Gmsh uses extensively for constructive solid geometry and for importing STEP files. You don't need OpenCASCADE to build geometrical models with Gmsh's built-in (geo) kernel, but you'll need it to import STEP and IGES files.

On most Linux distributions you can just install the occt development package(s), e.g. libocct-foundation-dev, libocct-data-exchange-dev, etc.

On other platforms, or if you just want to compile OpenCASCADE from source, first make sure that you have the Freetype libraries installed on your system (OpenCASCADE depends on them). If not available, download and install them (here for Freetype 2.8):

curl -O http://download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.gz
tar zxvf freetype-2.8.tar.gz
cd freetype-2.8
./configure
# Notes:
# * if you don't have root access, add --prefix==path-to-install
make
sudo make install
# Notes:
# * if you don't have root access, remove "sudo"

To compile OpenCASCADE (here for OCCT 7.3.0):

curl -L -o occt.tgz "http://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=refs/tags/V7_3_0;sf=tgz"
tar zxf occt.tgz
cd occt-V7_3_0
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_MODULE_Draw=0 -DBUILD_MODULE_Visualization=0 -DBUILD_MODULE_ApplicationFramework=0 ..
# Notes:
# * if you installed dependencies (e.g. Freetype) in non-standard locations, add the option -DCMAKE_PREFIX_PATH=path-of-installed-dependencies
# * if you don't have root access, add -DCMAKE_INSTALL_PREFIX=path-to-install
# * to build static libraries, add -DBUILD_LIBRARY_TYPE=Static
make
sudo make install
# Notes:
# * if you don't have root access, remove "sudo"

FLTK

Gmsh's graphical user interface uses the FLTK widget toolkit. You only need FLTK if you plan to use Gmsh's graphical (interactive) features.

On most Linux distributions you can just install the fltk development package(s), e.g. libfltk1.3-dev.

On other platforms, or if you just want to compile FLTK from source (here for FLTK 1.3.4):

curl -O http://fltk.org/pub/fltk/1.3.4/fltk-1.3.4-2-source.tar.gz
tar zxvf fltk-1.3.4-2-source.tar.gz
cd fltk-1.3.4-2
./configure 
# Notes:
# * by default FLTK is compiled as a static library, which has been reported to cause issues with OpenGL libraries on some systems; to build a shared library, add --enable-shared
# * if you don't have root access, add --prefix==path-to-install
make
sudo make install
# Notes:
# * if you don't have root access, remove "sudo"

Gmsh

You can then compile Gmsh as follows:

git clone http://gitlab.onelab.info/gmsh/gmsh.git
cd gmsh
mkdir build
cd build
cmake ..
# Notes: 
# * if you installed dependencies (e.g. OpenCASCADE and FLTK) in non-standard locations, add the option -DCMAKE_PREFIX_PATH=path-of-installed-dependencies
# * to enable parallel meshing, add the option -DENABLE_OPENMP=1
# * to build the Gmsh app as well as the dynamic Gmsh library (to develop e.g. using the C++ or the Python Gmsh API), add the option -DENABLE_BUILD_DYNAMIC=1
# * for a list of all available configuration options see http://gmsh.info/doc/texinfo/gmsh.html#Compiling-the-source-code
make

Windows environment

While Gmsh can be built on Windows using Microsoft Visual Studio, the official Windows binaries are produced using Cygwin and the MinGW compilers. The resulting binaries do not depend on the Cygwin DLL, i.e. are pure Windows executables. Follow the instructions below to set up a build environment similar to the one we use.

Cygwin and MingW compilers

Install Cygwin from https://www.cygwin.com. Accept all defaults and select View "Full". Install the following packages:

  • mingw64_x86_64-gcc-g++
  • mingw64_x86_64-gcc-fortran
  • cmake
  • make
  • openssh
  • python3
  • autoconf
  • automake
  • openssh
  • git
  • wget
  • unzip

Also useful for debugging

  • gdb

Also useful for editing text files

  • emacs-w32

Set up PATH

Type "path" in the Windows search box and choose "Edit the system environment variables". Go to "Advanced" and select "Environment variables". If the PATH variable does not exist (note the ALL CAPS!), create it and set it to

C:\cygwin64\usr\local\bin\;C:\cygwin64\usr\local\lib;C:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin

If PATH already exists, append the value (don't forget the semicolon!).

Set up the Cygwin terminal and Bash environment variables

Open the Cygwin terminal.

Edit the ~/.bash_profile and add the following at the end:

export PATH="${PATH}:/usr/x86_64-w64-mingw32/sys-root/mingw/bin:/usr/local/bin"
export CXX=x86_64-w64-mingw32-g++
export CC=x86_64-w64-mingw32-gcc
export FC=x86_64-w64-mingw32-gfortran

Then

cd
source .bash_profile
Clone repository
  • First Gmsh Workshop
  • Git cheat sheet
  • Gmsh compilation
  • Second Gmsh Workshop
  • Third Gmsh Workshop
  • Home