#1 : Make sure that you have basic compilers installed. For this run the command:
sudo apt-get install build-essential
#2 : Install few packages that required. Run the command:
sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-1.8 guile-1.8-dev libsdl1.2debian 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
#3 : Now download libgraph.
Copy libgraph-1.0.2.tar.gz to your home folder. Right click on it and select "Extract Here".
Then run following commands one by one.
cd libgraph-1.0.2
./configure
sudo make
sudo make install
sudo cp /usr/local/lib/libgraph.* /usr/lib
#4 : Now Ubuntu is ready to run graphics program. To do that add #include<graphics.h> in your C program.
>>In Turbo C we use following lines
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
>>In Ubuntu instead of "c:\\tc\\bgi" write NULL
int gd=DETECT,gm;
initgraph(&gd,&gm,NULL);
#5 : Run it with following command:
gcc sample.c -o sample -lgraph
./sample
sample.c
#include <stdio.h>#include <graphics.h>int main() { int gd = DETECT, gm; initgraph(&gd, &gm, NULL); line(0,getmaxy()/2,getmaxx(),getmaxy()/2); line(getmaxx()/2,0,getmaxx()/2,getmaxy()); setcolor(BLUE); circle(getmaxx()/2,getmaxy()/2,150); setcolor(GREEN); circle(getmaxx()/2,getmaxy()/2,75); setcolor(RED); circle(getmaxx()/2,getmaxy()/2,25); delay(5000); getch(); closegraph(); return 0;}sources: computer solutions