Install libgraph library in GCC
Use sudo for Ubuntu, Zorin, Uber Student, Ultimate...
su for others.
Step #1.Install the following in Synaptic Package Manager
- build-essential
- libsdl-image1.2
- libsdl-image1.2-dev
- libsdl-ttf2.0
- guile-1.8-dev
- guile-1.8
sudo apt-get install build-essential 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 #2. Download and Extract libgraph then run inside libgraph... directory in Super User Mode
- ./configure
- make
- make install
Step #3 Include graphics.h in your C program . Initialize the graphics system by
Step #4 you need to copy all the libgraph shared files from /usr/local/lib to /usr/lib
- int gd=DETECT, gm=VGAMAX;
- initgraph(&gd, &gm, NULL);
Step #4 you need to copy all the libgraph shared files from /usr/local/lib to /usr/lib
- cp /usr/local/lib/libgraph.* /usr/lib
Compile : gcc filename.c -lgraph
Example:
#include<stdio.h>
#include<graphics.h>
int main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,NULL);
int i,x=10;
char str[3]="0";
setbkcolor(WHITE);
setcolor(12); //outline heart
circle(50,50,40);
circle(110,50,40);
line(22,80,80,140);
line(80,140,138,80);
floodfill(50,50,12); //fill heart
floodfill(110,50,12);
floodfill(80,50,12);
floodfill(80,100,12);
getch();
closegraph();
return 0;
}
No comments:
Post a Comment
Any Suggestion or Complain