How to – Do C/C++ graphics program in Ubuntu // install libgraph (graphics.h) in Ubuntu. 

In my last post under the category of Ubuntu, I have shown you how you can easily setup Ubuntu as VM (virtual machine) under VirtualBox. And today we are going to talk about installing libgraph (graphics.h) in Ubuntu.

Linux is very popular in the world of developers because it sports some built-in compilers out of the box like popular GCC compiler for C/C++ development. But some of the development tools we have to download via internet like one is if we have to do basic graphics development under Ubuntu then we should install libgraph libraries under Ubuntu which contains graphics.h header file and other important files for development. Basically, libgraph is not the part of the GNU project that’s why it doesn’t come preinstalled with Linux distributions.

But What is Libgraph??

Libgraph is the implementation of the TurboC graphics API on GNU/Linux using SDL. You can get more info here.

You might think that one can easily install libgraph just downloading the files from here. And configuring and installing on Ubuntu machine. But it isn’t simple, Wait. If you read carefully What is a libgraph section in the post you will notice, there is pre-requisite to install libgraph. And that is SDL packages. As libgraph is fully dependent upon SDL, we have to first install them. SDL stands for Simple DirectMedia Layer. Which is the platform on which our graphics program runs? And FYI Ubuntu doesn’t provide this out of the box. So follow the following simple steps to install required SDL version.

Steps to install SDL.

1. Open terminal. (ctrl + shift + T).

2. And copy pastes the following command and hit enter. It will download and update the packages in your system. (it requires internet connection).

sudo apt-get update

3. After that execute the following command to install SDL packages. (copy paste following command in terminal)

sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-1.8 guile-1.8-dev

This command will install required SDL packages from internet.

Steps to Install libgraph in Ubuntu.
1. After that just download this libgraph installation files from the following link.

Download Libgraph files.

2. Then copy the package to the home directory. And extract it there.

3. Once it extracted open the folder. And right click on empty space and click on ‘Open in terminal’.

4. In terminal execute following command one by one.

. /configure

sudo make install

sudo cp /usr/local/lib/libgraph.* /usr/lib

5. And done. You have successfully installed libgraph. To check its installation type man libgraph and it will show up a manual page of libgraph.
And one more thing. You can compile a graphics program by typing following I will terminal.

For C++ program

g++ <program_name>.cpp – lgraph

For C program

gcc <program_name>.c – lgraph

And also don’t forget to replace <program_name> to your actual program name.

If you encountered any problem while doing this, then make sure that you hit comment below about that.



7 thoughts on “How to – Do C/C++ graphics program in Ubuntu // install libgraph (graphics.h) in Ubuntu. 

  1. Can you please help me out !!
    I am getting error while executing the command ” sudo make install ” … the error is ” make: No rule to make target ‘install’. Stop
    how can I go through it !!


      1. Now while executing the 3rd step that has been given above. It gives me the error as ” Package ‘guile-1.8-dev’ has no installation candidate
        what shall be done for this now !!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s