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

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

  • October 14, 2016 at 11:35 pm
    Permalink

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

    Reply
  • October 14, 2016 at 11:42 pm
    Permalink

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

    Reply
    • October 15, 2016 at 1:59 pm
      Permalink

      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.

      Reply
  • October 15, 2016 at 1:14 am
    Permalink

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

    Reply
  • October 15, 2016 at 1:17 am
    Permalink

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

    Reply
    • October 15, 2016 at 1:55 pm
      Permalink

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

      Reply
  • October 26, 2016 at 2:12 am
    Permalink

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

    Reply
    • October 26, 2016 at 2:14 am
      Permalink

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

      Reply
  • October 26, 2016 at 7:27 pm
    Permalink

    What is build essential used for?

    Reply
  • October 26, 2016 at 7:30 pm
    Permalink

    The Build Essential is a reference for other packages. It is a meta package which contains tools and softwares such as G++, GCC and many others to compile and build other softwares from cratch.

    Reply
  • November 8, 2016 at 10:17 pm
    Permalink

    The graphics.h library is deprecated now I think, especially in Ubuntu.

    Reply
  • November 21, 2016 at 10:17 pm
    Permalink

    Amazing solution. Now, I can easily compile and run graphics programs in C language.

    Reply

Join The Discussion