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;
initgraph(&gd,&gm,”c:\\tc\\bgi”);

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

int gd=DETECT,gm;
initgraph(&gd,&gm,NULL);

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

$./design
now see the design 🙂

start:-

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

end-:

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

Advertisements

One thought on “Graphics.h in ubuntu

  1. Face problem while installing packages. After search little on goouse gle then i find a solution that solve the problem.
    I use “sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-1.8 guile-1.8-dev”
    instead of command that you provide in post
    Thanks.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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