Debugging link error

This is a discussion on Debugging link error within the C Programming forums, part of the General Programming Boards category; Hey ppl, i'm having a problem. I'm a C newbie and i got and Link error when i was building ...

  1. #1
    Registered User bubux's Avatar
    Join Date
    Jul 2002
    Posts
    14

    Debugging link error

    Hey ppl, i'm having a problem. I'm a C newbie and i got and Link error when i was building my program.
    I'm currently using Turbo C2. It compiles all code OK but when it's gonna link, it generates following error:

    Code:
    Linker Error: Undefined symbol '_StatusLine' in module AT.C

    The thing is _StatusLine isn't even written in my code, i don't use it. Perhaps it's nested in an header file.

    What do you think? How can i debugg Link errors?
    <VBCODE>
    While Bubux.State = "alive"
    Bubux.LoveGod = True
    Wend
    </VBCODE>

  2. #2
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    Linker Error: Undefined symbol '_StatusLine' in module AT.C
    You get this error when you have called a function in your program and the linker is unable to find this function neither in your program nor in the path where your linker looks up the libraries consisting of functions.
    You now have only two choices, write the code for this function all by yourself or locate the library containing this function.
    Last edited by shaik786; 07-06-2002 at 05:59 AM.

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    >The thing is _StatusLine isn't even written in my code

    It could be that you're using a function in your code which calls this functions. Search your documentation for this function, especially search for the library which contains this function. Then add this library to your linker options, makefile or project.

  4. #4
    Registered User bubux's Avatar
    Join Date
    Jul 2002
    Posts
    14

    But..

    But I still can't find the function. If you have an idea...
    I'm currently using Turbo C2.
    I'm using only standard includes except for 'keys.h' wich contains keycode constants as you can see bellow:



    Code:
    /*
    	AT.C - ALIENTECH PROJECT MAIN FILE
    
    	AlienTech is an open-source project under GPL (General Public License)
    	For more about AlienTech visit http://alientech.sourceforge.net/
    	For more about GPL visit http://www.gnu.org/
    
    */
    
    #ifdef __TINY__
    #error BGIDEMO will not run in the tiny model.
    #endif
    
    #include <dos.h>
    #include <math.h>
    #include <conio.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <stdarg.h>
    #include <graphics.h>
    #include <keys.h>			/* Keyboard cosntants definition	*/
    
    #define TRUE		1		/* Define some handy constants	*/
    #define FALSE		0		/* Define some handy constants	*/
    #define PI		3.14159 	/* Define a value for PI	*/
    #define ON		1		/* Define some handy constants	*/
    #define OFF		0		/* Define some handy constants	*/
    
    #define BTHICK  	3		/* Define general border thick	*/
    #define BCOLOR1  	15		/* Define border color1 = white	*/
    #define BCOLOR2  	3		/* Define border color2 = gray	*/
    
    int	GraphDriver;		/* The Graphics device driver		*/
    int	GraphMode;		/* The Graphics mode value		*/
    double	AspectRatio;		/* Aspect ratio of a pixel on the screen*/
    int	MaxX, MaxY;		/* The maximum resolution of the screen */
    int	MaxColors;		/* The maximum # of colors available	*/
    int	ErrorCode;		/* Reports any graphics errors		*/
    struct	palettetype palette;		/* Used to read palette info	*/
    
    /*									*/
    /*	Function prototypes						*/
    /*									*/
    
    void Initialize(void);
    void Pause(void);
    void DrawButton(int Bheight, int Bwidth, int BX, int BY, int BState);
    void DrawRectBorder(int Bheight, int Bwidth, int BX, int BY, int BState);
    void DrawMainWindow(void);
    
    /*									*/
    /*	Begin main function						*/
    /*									*/
    
    int main()
    {
    
      Initialize(); 		/* Set system into Graphics mode	*/
      DrawMainWindow();		/* Draw main program window		*/
      Pause();			/* Pause the program. Wait for keypress	*/
      closegraph(); 		/* Return the system to text mode	*/
      return(0);
    }
    
    
    /*									*/
    /*	INITIALIZE: Initializes the graphics system and reports 	*/
    /*	any errors which occured.					*/
    /*									*/
    
    void Initialize(void)
    {
      int xasp, yasp;			/* Used to read the aspect ratio*/
    
      GraphDriver = DETECT; 		/* Request auto-detection	*/
      initgraph( &GraphDriver, &GraphMode, "" );
      ErrorCode = graphresult();		/* Read result of initialization*/
      if( ErrorCode != grOk ){		/* Error occured during init	*/
        printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) );
        exit( 1 );
      }
    
      getpalette( &palette );		/* Read the palette from board	*/
      MaxColors = getmaxcolor() + 1;	/* Read maximum number of colors*/
    
      MaxX = getmaxx();
      MaxY = getmaxy();			/* Read size of screen		*/
    
      getaspectratio( &xasp, &yasp );	/* read the hardware aspect	*/
      AspectRatio = (double)xasp / (double)yasp; /* Get correction factor	*/
    
    }
    
    
    /*									*/
    /*	PAUSE: Pause until the user enters a keystroke. If the		*/
    /*	key is an ESC, then exit program, else simply return.		*/
    /*									*/
    
    void Pause(void)
    {
      static char msg[] = "Esc aborts or press a key...";
      int c;
    
      StatusLine( msg );			/* Put msg at bottom of screen	*/
    
      c = getch();				/* Read a character from kbd	*/
    
      if( cEsc == c ){			/* Does user wish to leave?	*/
        closegraph();			/* Change to text mode		*/
        exit( 1 );				/* Return to OS 		*/
      }
    
      if( 0 == c ){ 			/* Did use hit a non-ASCII key? */
        c = getch();			/* Read scan code for keyboard	*/
      }
    
      cleardevice();			/* Clear the screen		*/
    
    }
    
    
    /*									*/
    /*	DRAWMAINWINDOW: draws the main program window.			*/
    /*									*/
    
    void DrawMainWindow(void)
    {
    
      cleardevice();			/* Clear graphics screen	*/
      DrawRectBorder( 10, 10, MaxX-10, MaxY-10, OFF );	/* Draw WindowBorder	*/
      DrawButton(50, 200, 100, 100, OFF);
    }
    
    
    /*									*/
    /*	DRAWRECTBORDER: draws a border. Can be raised or pressed	*/
    /*	(usefull for drawing buttons and windows' borders		*/
    
    void DrawRectBorder( int Bheight, int Bwidth, int BX, int BY, int BState )
    {
      int Colr1 = BCOLOR1;
      int Colr2 = BCOLOR2;
    
      if ( BState == ON )
      {
        Colr1 = BCOLOR2;
        Colr2 = BCOLOR1;
      }
    
      cleardevice();			/* Clear graphics screen	*/
      setlinestyle( SOLID_LINE, 0, BTHICK );	/* Set line to thick and solid	*/
    
      setcolor( Colr1 );			/* Set current color		*/
      line( BX, BY + Bheight, BX, BY );	/* Draw border line		*/
      lineto( BX + Bwidth, BY );		/* Draw border line		*/
    
      setcolor( Colr2 );			/* Set current color		*/
      lineto( BX + Bwidth, BY + Bheight );	/* Draw border line		*/
      lineto( BX, BY + Bheight );		/* Draw border line		*/
    
    }
    
    
    
    
    /*									*/
    /*	DRAWBUTTON: draws a button. Can be ON/OFF (pressed/free)	*/
    /*									*/
    
    void DrawButton(int Bheight, int Bwidth, int BX, int BY, int BState)
    {
    
      cleardevice();			/* Clear graphics screen	*/
      setlinestyle( SOLID_LINE, 0, BTHICK );	/* Set line to thick and solid	*/
    
      if ( BState == ON ) 
      {
    
        setcolor( BCOLOR2 );		/* Set current color		*/
        line( BX, BY + Bheight, BX, BY );	/* Draw border line		*/
        lineto( BX + Bwidth, BY );		/* Draw border line		*/
    
        setcolor( BCOLOR1 );		/* Set current color		*/
        line( BX + BTHICK, BY + Bheight, BX + BTHICK, BY + BTHICK );	/* Draw border line	*/
        lineto( BX + Bwidth, BY + BTHICK );	/* Draw border line		*/
    
      }
    
      else if ( BState == OFF ) 
      {
    
        setcolor( BCOLOR1 );		/* Set current color		*/
        line( BX, BY + Bheight, BX, BY );	/* Draw border line		*/
        lineto( BX + Bwidth, BY );		/* Draw border line		*/
    
        setcolor( BCOLOR2 );		/* Set current color		*/
        lineto( BX + Bwidth, BY + Bheight );	/* Draw border line	*/
        lineto( BX, BY + Bheight);		/* Draw border line		*/
    
      }
    
    }
    <VBCODE>
    While Bubux.State = "alive"
    Bubux.LoveGod = True
    Wend
    </VBCODE>

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,558
    > But I still can't find the function
    It's right there in Pause()

    StatusLine( msg ); /* Put msg at bottom of screen */

    It's not uncommon for compilers to put underscores in front of your symbol names

    As for where you would find the symbol, perhaps it's in another source file or library.

  6. #6
    Registered User bubux's Avatar
    Join Date
    Jul 2002
    Posts
    14

    What a shame!

    Originally posted by Salem
    > But I still can't find the function
    It's right there in Pause()

    StatusLine( msg ); /* Put msg at bottom of screen */

    It's not uncommon for compilers to put underscores in front of your symbol names

    As for where you would find the symbol, perhaps it's in another source file or library.
    Ahhhh... What a shame for me! I thought that func was in Graphics.h... But it wasn't. I remove it and it worked.

    PROBLEM SOLVED
    <VBCODE>
    While Bubux.State = "alive"
    Bubux.LoveGod = True
    Wend
    </VBCODE>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 03:09 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  3. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 06:17 PM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21