Install and Run Graphics.h in Ubuntu

Install and Run Graphics.h in Ubuntu OS (Complete Tutorial)

Learn How To Install and Run Graphics.h in Ubuntu Operating System. Install Graphics Package Libgraph in Linux Ubuntu OS.

The GNU GCC Compiler which is the default C and C++ Compiler in Ubuntu does not include graphics header files in its directory. Therefore, the inclusion of the preprocessor directive #include<graphics.h> will not work. It will give an error saying graphics.h not found.

The graphics.h is a Header File in C Programming that helps you to include functions related to graphics in your C Program.

Install and Run Graphics.h in Ubuntu

By default, the Graphics Header File <graphics.h> does not work in Ubuntu for C and C++ Programming. We need to explicitly install the graphics package Libgraph to enable Graphics in C Programming.

1. Download Libgraph File

Download Graphics Package For Ubuntu Here: Libgraph

2. Install Build Essentials

3. Install Packages To Run Graphics.h Header File

4. Extract the File

You can extract a file in linux using two methods:

a. Right click on the compressed file and extract it in the same folder

b. Execute a Linux command to untar the Libgraph file

5. Copy Extracted Libgraph Folder into USR Directory

6. Compile A C Program with Graphics Header File

There are many libraries other than Libgraph to develop graphics programs in Linux. Libgraph is an old library. You should try your hands on OpenGL which is a high performance graphics library.

Sample Graphics Program in C Language

If you have any compilation errors or doubts in installing graphics.h header files in Ubuntu, let us know about it in the comment section below.

Tushar Soni

I am Tushar Soni, Co - Founder of CodingAlpha. I am a computer science student from India and passionate about Web Development and Programming. Connect with me on Facebook | LinkedIn | Google Plus

8 thoughts on “Install and Run Graphics.h in Ubuntu

  • October 14, 2016 at 11:35 pm

    The Libgraph package is too old. OpenGL is very much in demand and you people should use it for graphics in C Programming.

  • October 14, 2016 at 11:42 pm

    Hi! I got an Error! It says – “configure: error: *** SDL version 1.2.0 not found!”. Please help.

    • October 15, 2016 at 1:59 pm

      This is another very common error that I found very often while installing graphics.h package in my Linux ubuntu machine. To solve this, you need to type the following command in your Linux Terminal:
      sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev
      This sill install some important and related packages.

  • October 15, 2016 at 1:14 am

    Thanks. I am able to run graphics libraries in my Linux Mint now.

  • October 15, 2016 at 1:17 am

    I am getting the following error while installing Graphics Libgraph package. It says – “cannot find guile-config”.

    • October 15, 2016 at 1:55 pm

      Try the following command in your Linux Terminal. It will install guile package in your Ubuntu machine.
      sudo apt-get install guile guile-dev

  • October 26, 2016 at 2:12 am

    In the above paragraph, you have mentioned about GLUT. Can you tell me how to download it in linux ubuntu?

    • October 26, 2016 at 2:14 am

      Okay. You can download and install GLUT in Ubuntu via Ubuntu Terminal using the following command:
      sudo apt-get install freeglut3-dev


Join The Discussion