Getting Started

What is it?

GMSH is an open-source software for 2D/3D mesh and data visualization, developped in Belgium by (mainly) C. Geuzaine and J-F. Remacle.

Install (without being root!)

Linux user: please do not install GMSH via package manager (apt-get, …): version is outdated.

From scratch (advanced users)

Source code are available on Onelab’s Gitlab and GMSH can be compiled by hand.

The easiest way to install GMSH is to simply download the binary files for Linux/Windows/Mac, either Stable or Latest automatic Gmsh snapshot (recommended (by me)). The binary file gmsh is located in bin/gmsh in the compressed downloaded file. You can launch it directly

cd folder/of/gmsh/bin

Apart from (maybe) the color theme, a new window should have been launched and looks like this

GMSH splash screen. GMSH’s version is displayed at the bottom of the window (here 4.5.0)

Add gmsh to your $PATH

Never copy a binary file in usr/bin. This folder is reserved to your package manager.

For Linux (and Mac) users, it might be convenient to be able to launch GMSH in a terminal and from whichever folder. To do that, simply add to the $PATH environment variable, the path to gmsh's folder. This can be automated by adding a line in $HOME/.bash_profile (or $HOME/.profile or …)

export PATH=$PATH:/path/to/gmsh

You must rerun your shell to get the changes applied (or usr source command).

[Beginnner] How to manage your files?

A question that quickly arises is:

Where and how do I store every binary and lib files without making my computer a full mess?

Good question.

There are multiple answers and here you’ll find one which you may like (or not). I like to have a $HOME/install folder (local to my account, thus) which mimic the /usr/ folder, i.e. containing bin, lib, share and include folders:

      └── bin/      # binary files
          └── gmsh    #some binaries (gmsh, ...)
      └── lib/      # library files
      └── share/      # dynamic libraries
      └── include/    # header files

I then set the $PATH environment variable to

export PATH=$PATH:$HOME/install/bin

Every time I add a new file to $HOME/install/bin it becomes accessible, without having to change the environment variable.

Actually I have three main folders

  • $HOME/src : Source codes
  • $HOME/build : Where the source codes are compiled
  • $HOME/install : Installed software that I either compiled or downloaded

This way, source code, build process and installed file are well separated.


Part of the tutorial is written in GMSH’s language but using the API instead is direct and highly recommended.

GMSH provides a powerful API compatible with Python, Julia or C++. The GMSH SDK1 is available online and easy to install.

Local in the folder (meh)

For example on Unix system and for Python, a way to install it locally (without being root) and by hand ("à la hussarde") is to add this in this in the header of your Python file

import sys
sys.path.insert(0, "/path/to/sdk/lib")
import gmsh

Permanent linking (better)

A better method is to use the $PYTHONPATH environment variable and set it to the SDK’s folder. Following the previous paragraph, create a folder install at your $HOME folder and copy the content of lib folder of the SDK’s zip file inside $HOME/install/lib. You would then have this stucture

      └── lib/      # library files

You have now to add to Python the path:

export PYTHONPATH=$HOME/install/lib

A relaunch of the terminal might be necessary to take these changes into account. In your Python code, you juste have to import gmsh without any other condition

import gmsh
The binary file bin/gmsh contained in the SDK’s zip file might not work as a standalone binary file. Please download and use the binary provided by GMSH’s website for that use.

  1. Software Development Toolkit ↩︎