Graphics.h in ubuntu

How to use Graphics.h in ubuntu?

Now you can use Graphics.h in ubuntu with gcc compiler.You just have to follow these few steps to install.

Step #1
Make sure that you have installed basic compilers for this just open terminal by using ctrl+alt+t, then type this commond.

$sudo apt-get install build-essential

Step #2
After that we have to install these packages. You just simply type this command in terminal.

$sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-1.8 guile-1.8-dev libsdl1.2debian-all libart-2.0-dev libaudiofile-dev libesd0-dev libdirectfb-dev libdirectfb-extra libfreetype6-dev libxext-dev x11proto-xext-dev libfreetype6 libaa1 libaa1-dev libslang2-dev libasound2 libasound2-dev

Step #3
Now download this libgraph

Now extract it into home folder and run following commands

  • $cd libgraph-1.0.2
  • $./configure
  • $sudo make
  • $sudo make install
  • $sudo cp /usr/local/lib/libgraph.* /usr/lib

Now you are ready to compile your graphics program
To Compile a graphics program
First make program
In programs using graphics.h in Turbo C, you’ll be using something like this:

int gd=DETECT,gm;

In Ubuntu, you replace the “c:\\tc\\bgi” part with a NULL

int gd=DETECT,gm;

now make your program and compile it. 🙂
for example I have made design.c
then compile it by

$gcc design.c -o design -lgraph

then run it by

now see the design 🙂


Screenshot from 2014-02-01 20:40:34      


Screenshot from 2014-02-01 20:43:32