C GRAPHICS
Hey. I had just started work on a certain BGI graphics mini project, when I discovered a totally new problem. Whenever I try to compile the program below, it gets compiled with no errors and no warnings. However, when I try to run the program, I get linker errors related to each of the functions defined in graphics.h
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#define XINTERVAL 100
/////////////////////////////////////////////////////////////////////
void showgraph()
{
int gd=DETECT,gm,currentx,ctr,ctr2;
clrscr();
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
moveto(1,1);
currentx=1;
setcolor(BLUE);
ctr2=0;
ctr=1;
while(getx()<=getmaxx())
{
line(currentx,1,currentx,getmaxy());
ctr++;
currentx=XINTERVAL*ctr2+log10(ctr)*XINTERVAL;
if(ctr==10)
{
ctr=1;
ctr2++;
}
}
getch();
closegraph();
restorecrtmode();
}
/////////////////////////////////////////////////////////////////////
int main()
{
clrscr();
showgraph();
getch();
return(0);
}
ERROR :
Linker Error: Undefined symbol _restorecrtmode in module NONAME00.CPP
Linker Error: Undefined symbol _closegraph in module NONAME00.CPP
Linker Error: Undefined symbol _getmaxx in module NONAME00.CPP
Linker Error: Undefined symbol _getx in module NONAME00.CPP
Linker Error: Undefined symbol _line in module NONAME00.CPP
Linker Error: Undefined symbol _getmaxy in module NONAME00.CPP
Linker Error: Undefined symbol _setcolor in module NONAME00.CPP
Linker Error: Undefined symbol _moveto in module NONAME00.CPP
Linker Error: Undefined symbol _cleardevice in module NONAME00.CPP
Linker Error: Undefined symbol _initgraph in module NONAME00.CPP
The program seems simple enough, so I am unable to understand why I should get any errors at all. The problem is that I am writing a BGI graphics program after a very long time, and did not anticipate any problem. Moreover, programs that I had earlier written and compiled correctly, now give me the same errors when I try to run them from within the compiler. What could be the problem?
Solution :
Just browse to Options>Linker>Libraries>
and select the option "Graphics Libraries"
AND SAVE
Comments