How to Install Mesa (OpenGL) on Linux Mint

Mesa is an open-source implementation of the OpenGL specification - a system for rendering interactive 3D graphics. Technically, OpenGL is just a specification, implemented by your graphics driver. There's no such thing like an OpenGL SDK library. There's just libGL.so which comes with your driver. To use it, you need bindings for your programming language of choice. If that is C, the "bindings" consist of just the header files. However you'll probably also want to use OpenGL extensions, which is easy using GLEW.


A variety of device drivers allows Mesa to be used in many different environments ranging from software emulation to complete hardware acceleration for modern GPUs. Mesa ties into several other open-source projects: the Direct Rendering Infrastructure and X.org to provide OpenGL support to users of X on Linux, FreeBSD and other operating systems.

Preparing Your Linux Mint Operating System for OpenGL Development

Open a terminal and enter the following commands to install the necessary libraries for OpenGL development:

  • Enter sudo apt-get update
  • Enter sudo apt-get install freeglut3
  • Enter sudo apt-get install freeglut3-dev
  • Enter sudo apt-get install binutils-gold
  • Enter sudo apt-get install g++ cmake
  • Enter sudo apt-get install libglew-dev
  • Enter sudo apt-get install g++
  • Enter sudo apt-get install mesa-common-dev
  • Enter sudo apt-get install build-essential
  • Enter sudo apt-get install libglew1.5-dev libglm-dev

Get information about the OpenGL and GLX implementations running on a given X display.

To do this, enter glxinfo .

Creating Your First OpenGL Program

Open up a terminal.

Make a directory, change into the directory and use your favorite text editor such as nano or gedit to create your OpenGL source code. Enter the following commands below.

  • Enter mkdir Sample-OpenGL-ProgramsThis will create a directory to hold your OpenGL programs.
  • This will create a directory to hold your OpenGL programs.
  • Enter cd Sample-OpenGL-ProgramsThis will change you into your directory.
  • This will change you into your directory.
  • Enter nano main.c OR gedit main.c

Copy and paste OR type the code:

Save the file and exit.

Compiling and Running Your OpenGL Application

Enter the Sample-OpenGL-Programs directory.

While there, run the following command:

  • g++ main.c -lglut -lGL -lGLEW -lGLU -o OpenGLExampleThis command will compile and link your OpenGL libraries.
  • This command will compile and link your OpenGL libraries.

Run the program.

To do this, type the following:

  • Enter ./OpenGLExample

Wait for a result.

If you did everything right, a window will open. It will show a white square on a black background. The window will be titled “OpenGL – First window demo”.

Leave a Comment