Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yahoo!, Bing, Majestic-12

Members: 0
Guests: 6
Stats
Files
Topics
Posts
Members
Newest Member
477
3,706
19,240
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » undefined reference to '_vari...
Forum Rules | Mark all | Recent Posts

undefined reference to '_variable'
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Oct 21, 2010, 5:40 pm   Last edited Oct 21, 2010, 5:43 pm by bobo the bee
Go to the top of the page
Go to the bottom of the page

bobo the bee
Fledgling
GroupMembers
Posts12
JoinedJan 19, 2010

(Also seen on MudBytes.net)

So, in trying to add a new global variable to keep track of the last color used by the MUD, but I've run into a bit of an issue. The code itself compiles, up until the very end when I receive this error message:

$make -s smaug
  Compiling o/color.o....
o/color.o: In function `_Z11set_lastcolPc':
.../quarulid/src/color.c:1878: undefined reference to `_last_col'
.../quarulid/src/color.c:1884: undefined reference to `_last_col'
collect2: ld returned 1 exit status
make[1]: *** [smaug] Error 1
make: *** [all] Error 2


However, in mud.h I certainly have this:
extern char last_col[2];


The code the uses last_col is:
void set_lastcol( char *col )
{
	char thecol[2] ;

	if( !col && !IS_NULLSTR(col))
	{
		thecol[0] = 'x' ;
		thecol[1] = '\0' ;
		mudstrlcpy( last_col , thecol, 2 ) ;
		return ;
	}

	thecol[0] = col[0] ;
	thecol[1] = '\0' ;
	mudstrlcpy( last_col , thecol, 2 ) ;

	return ;
}

       
Post is unread #2 Oct 21, 2010, 7:40 pm   Last edited Oct 21, 2010, 7:40 pm by bobo the bee
Go to the top of the page
Go to the bottom of the page

bobo the bee
Fledgling
GroupMembers
Posts12
JoinedJan 19, 2010

Not surprisingly, the error was exactly what the compiler had said.

Tyche said:

All I see is a declaration of last_col.
You don't define last_col anywhere in your program.

Maybe this page will help: TutorialFunctionDeclarationsAndDefinitions

What "extern char last_col[2];" means to the compiler is that there exists a variable called last_col somewhere.
It doesn't define it.


Bobo the bee said:

And, yep, this was indeed the problem. Not being used to larger-scale programs, I keep forgetting that setting something in a header file doesn't mean it exists as of yet. A simple error, and thanks for pointing it out. To any who might wonder, a declaration of

char last_col[2] ;


before set_lastcol() was the issue
       
Pages:<< prev 1 next >>