how can one resolve a linking problem in c graphics.h

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nipun sabharwal

    how can one resolve a linking problem in c graphics.h

    Code:
    void main()
    {
    	int gd=DETECT,gm;
    	initgraph(&gd,&gm,"c:\\tc\\bgi");
    	setcolor(GREEN);
    	settextstyle(4,0,8);
    	outtextxy(200,50,"TIME");
    	setcolor(YELLOW);
    	settextstyle(4,0,8);
    	outtextxy(100,190,"SCHEDULER");
    	settextstyle(1,0,1);
    	setcolor(RED);
    	outtextxy(480,350,"Made By:");
    	setcolor(BLUE);
    	outtextxy(480,370,"Atiq Anwar");
    	getch();
    	restorecrtmode();
    }
    
    
    error-
    linking error..undefined symbol setcolor
    linking error..undefined symbol settextstyle
    linking error..undefined symbol outtextxy
    linking error..undefined symbol restorecrtmode
    linking error..undefined symbol initgraph

    plzzzzzz help thnx alot
    Last edited by MMcCarthy; Oct 24 '10, 07:51 AM. Reason: added code tags
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    For example, you are using a symbol setcolor and the compiler doesn't know what that is.

    I don't know what that is either. Is a a variable? a function?

    You cannot use any symbol unless you have first declared what it is.

    Maybe you are missing a header file.

    BTW: main() returns int not void.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      This is a linker error, not a compiler error. That is, you are including the right header. This header promises the compiler that these functions exist and that they will be available for the link editor phase. However, the link editor can't find those functions so it complains that you broke your promise.

      Typically, promised external functions like these are either provided in an object file or an object library. The method of providing either of these varies by compiler.

      In gcc, you specify an object file by including it on the command line with all of the other input files; you specify an object library with the -l command line switch.

      Comment

      Working...