General build instructions are available in the top-level README. The commands used for the continuous integration builds and for the official releases are available in the .gitlab-ci.yml file.
This page contains more detailed instructions to compile a full-featured version of Gmsh, including the compilation of common dependencies: OpenCASCADE and FLTK. In addition to CMake and C++ and C compilers, you should have (preferably optimized) versions of the BLAS and LAPACK libraries on your system (e.g. OpenBLAS, ATLAS or the MKL).
OpenCASCADE is a free CAD kernel that Gmsh uses extensively for constructive solid geometry and for importing STEP files.
First make sure that you have the Freetype libraries installed on your system (OpenCASCADE depends on them). If not, download and install them (here for Freetype 2.8):
curl -O http://download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.gztar zxvf freetype-2.8.tar.gzcd freetype-2.8./configure# Notes:# * if you don't have root access, add --prefix==path-to-installmakesudo make install# Notes:# * if you don't have root access, remove "sudo"
To compile OpenCASCADE, download and uncompress the sources from the official site, then (here for OCCT 7.2.0):
curl -L-o occt.tgz "http://git.dev.opencascade.org/gitweb/?p=occt.git;a=snapshot;h=refs/tags/V7_2_0;sf=tgz"tar zxvf occt.tgzcd occt-V7_2_0mkdir buildcd buildcmake -DCMAKE_BUILD_TYPE=Release -DBUILD_MODULE_Draw=0 -DBUILD_MODULE_Visualization=0 -DBUILD_MODULE_ApplicationFramework=0 ..# Notes:# * if you installed dependencies (e.g. Free type) 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-installmakesudo make install# Notes:# * if you don't have root access, remove "sudo"
Gmsh's default graphical user interface uses the FLTK widget toolkit. To compile FLTK (here for FLTK 1.3.4):
curl -O http://fltk.org/pub/fltk/1.3.4/fltk-1.3.4-2-source.tar.gztar zxvf fltk-1.3.4-2-source.tar.gzcd fltk-1.3.4-2./configure # Notes:# * if you don't have root access, add --prefix==path-to-installmakesudo make install# Notes:# * if you don't have root access, remove "sudo"
Some Gmsh algorithms (relying on cross-fields or reparametrization) benefit from fast sparse linear solvers. Gmsh can use PETSc for this. To compile a sequential real arithmetic PETSc library (here for PETSc 3.7.4):
curl -O http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.7.4.tar.gztar zxvf petsc-3.7.4.tar.gzcd petsc-3.7.4export PETSC_DIR=$PWDexport PETSC_ARCH=real_mumps_seq./configure --with-clanguage=cxx --with-debugging=0 --with-mpi=0 --with-mpiuni-fortran-binding=0 --download-mumps=yes --with-mumps-serial--with-shared-libraries=0 --with-x=0 --with-ssl=0 --with-scalar-type=real# Notes:# * if your compilers are not found, specify them explicitly: e.g. --FC=/path/to/f90 for the fortran compiler# * if the BLAS/LAPACK libraries are not installed in standard locations, you will have to specify their location by hand with options --with-blas-lib=/path/to/libblas and --with-lapack-lib=/path/to/liblapack# * as a last recourse (but this will severely degrade performance), you can use generic non-optimized BLAS/LAPACK libraries by using the option --download-fblaslapack=1makecd ..
You can then compile Gmsh as follows:
git clone http://gitlab.onelab.info/gmsh/gmsh.gitcd gmshmkdir buildcd buildcmake ..# 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 build a distributed memory (MPI) capable version add the option -DENABLE_MPI=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-codemake