Question:
Turbo c++ , Linker Error., During drawing a circle?
2011-03-02 00:54:48 UTC
Hello friends this aditya and i am a beginner in turbo c++ language. So my problem is while i am drawing a circle by copying the example from the c++. I am getting 9 linker error. so i don't know how to solve it please help me out thank you .. below i am giving the Program okay thank you..

#include
#include
#include
#include

int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int radius = 100;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");

/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}

midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());

/* draw the circle */
circle(midx, midy, radius);

/* clean up */
getch();
closegraph();
return 0;
}
Four answers:
2011-03-02 02:19:13 UTC
The problem may that the graphics.lib is not included in the linking.



I do not use Turbo C, so all that I can do is to make the best guess.



Since you are getting 9 errors and there are 9 graphic functions called, I think I am right in my guess.



If you are using IDE to compile: you have to adjust the settings of linker.Go to Options>Linker > Libraries> and then check the ” Graphics Library“.This will help to solve the linker errors for the graphics programs.



If you are using command line compiler, use -lgraphics.lib command line parameter.



Make sure the graphics.lib is in path.



I am sorry if I am wrong, because I am writing this from the memory of things that were done more than 15 years back!

.
Princess Psycho
2011-03-02 01:41:05 UTC
Having checked and run the program it is fine there is no problem with the code, what might be the problem is the set up on your computer, the biggest problem may be that you have not got the program file in the right directory as ancient BGI graphics requires a file called evavga.bgi without it you can't run dos graphics. The other problems is that Turbo C++ is an ancient implementation and is out of date so it might be that you have not installed the computer properly without the linker errors it is difficult to diagnose your problems.
2016-04-28 02:42:34 UTC
see first you need to know what is a linker and what is a linker error. After code compilation, that code is linked with all the library functions existent in your turboC directory...Now, that is the job of the linker to find out the body of the functions u have used like printf, scanf etc...Now you have used one function called "symbol_circle" which you have declared and called from the main function but you havent declared the body of it...During linking time, the linker sees that the function is called but it has got no corresponding code to execute...write a body of that function.....then u will find no linker error will occur..
henry_yang67
2011-03-02 01:41:59 UTC
it's most likely that you don't have the build path setup properly and some of the library files are missing


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...