Building GLVis

A simple tutorial how to build and run GLVis together with MFEM. For more details, see the INSTALL file.


Starting with version 4.0, GLVis requires the following dependencies in order to build and run: SDL2, GLEW, GLM, Freetype, and Fontconfig. Optional dependencies include libpng and/or libtiff for taking screenshots.

Most of these dependencies can be installed through your system's package manager:

Ubuntu/Debian (apt-based)

apt-get install libfontconfig1-dev libfreetype-dev libsdl2-dev libglew-dev libglm-dev libpng-dev


dnf install fontconfig-devel freetype-devel SDL2-devel glew-devel glm-devel libpng-devel

Mac OS X (Homebrew)

brew install fontconfig freetype sdl2 glew glm libpng


Download MFEM and GLVis (below we assume that we are working with version 4.0)

Put everything in the same directory:

~> ls
glvis-4.0.tgz   mfem-4.2.tgz

Build the serial version of MFEM:

~> tar -zxvf mfem-4.2.tgz
~> cd mfem-4.2
~/mfem-4.2> make serial -j

Build GLVis:

~> tar -zxvf glvis-4.0.tgz
~> cd glvis-4.0
~/glvis-4.0> make MFEM_DIR=../mfem-4.2 -j

That's it! The glvis executable can be found in the glvis-4.0 directory.

Testing and rebuilding

To test the build, visualize a mesh with

~/glvis-4.0> ./glvis -m ../mfem-4.2/data/escher.mesh

To start a GLVis server, open a new terminal and start glvis without arguments

~/glvis-4.0> ./glvis

To rebuild GLVis after changes in MFEM (e.g. if MFEM has rebuild in parallel), do:

~/glvis-4.0> make clean
~/glvis-4.0> make MFEM_DIR=../mfem-4.2 -j

Using secure sockets

As of version 3.2, GLVis can be built with support for secure sockets using the GnuTLS library through MFEM's class socketstream. This option may be useful in multi-user environment to prevent users from sending/receiving visualization data to/from other users. To enable this support, first configure MFEM version 3.2 or later with

~/mfem-3.2> make config MFEM_USE_GNUTLS=YES

For more details consult MFEM's INSTALL file. After configuration, build MFEM and GLVis as usual:

~/mfem-3.2> make -j
~/mfem-3.2> cd ../glvis-3.2
~/glvis-3.2> make clean && make MFEM_DIR=../mfem-3.2 -j

In order to use the secure sockets with the GLVis server and client applications like MFEM's Example 1, one needs to generate GLVis server and client key pairs. The simplest way to do that is to use the script in the main GLVis directory:

~/glvis-3.2> bash "User Name" ""

The key generation requires the gpg2 tool from GnuPG. The generated keys are saved in ~/.config/glvis/server and ~/.config/glvis/client.

With this option enabled, GLVis will use secure sockets by default, as indicated by the additional message after the logo:

~/glvis-3.2> ./glvis

       _/_/_/  _/      _/      _/  _/
    _/        _/      _/      _/        _/_/_/
   _/  _/_/  _/      _/      _/  _/  _/_/
  _/    _/  _/        _/  _/    _/      _/_/
   _/_/_/  _/_/_/_/    _/      _/  _/_/_/

Generating DH params (1024 bits) ... done.
Waiting for data on port 19916 ...

The secure sockets can be disabled with the -no-sec or --standard-sockets command line options.