Undefined reference help

Posted by Mozzy on Mon 20 Oct 2003 09:03 PM — 11 posts, 31,537 views.

#0
Hey everyone again,

I worked out that other stuff, and got it down - which is cool. ^.^ Thanks for the help. I have run into a new problem though. I just patched a global_boards patch onto the MUD, and did the necessary changes the MUD said. Though when I did, I get error messages like;

comm.o(.text+0x5d43): In function 'nanny':
/smaug/dist/src/comm.c:2474: undefined reference to '_handle_con_note_to'
comm.o(.text+0x5d49): In function 'nanny':
/smaug/dist/src/comm.c:2478: undefined reference to '_handle_con_note_subject'

etc. It continues, having undefined refernece errors with '_handle_con_expire_', '_handle_con_text', '_handle_con_finish.

So yeah.. Basically, I wana know - what does undefined reference mean? I have defined all the commands (I am pretty sure) in MUD.h as well as in Tables.C and everything. Any clues?

Thanks again
- Mozz
USA #1
That means that your linker is not actually finding the function definition for the function in question.

This usually happens if, for example, you have:

[code]
extern int i;

int main()
{
printf("%d", i);
return 0;
}
[/code]

On its own, this will create an undefined reference error, because the compiler will not know where "i" is stored. However, since it's declared as an extern, the compiler will not produce a syntax/language error.

If you had to add a .c file with new functions in it, make sure you add it to your makefile.
Canada #2
I would say that since they have _con_ in the errors, it means that you may have missed adding the connection states to the list in mud.h . These states are used by nanny to decide what to display, normal game text, log in stuff, or, in your case, the note console. Look into that, hope it helps. 'Course I can't see your code, so I can't be certain.
Amended on Tue 21 Oct 2003 05:14 AM by Greven
#3
Hmm.. How do I add the new .c file to the makefile? I did add a new C file in there - I just assumed that the 'make' command just incorporated it automatically. So yeah, how do I do it?
USA #4
Use vi on 'makefile' in your src directory. You should see a list of .o files and .c files - or something like that. Actually it should be fairly clear where you need to add it... just stick it in the list. If you still have doubts just paste the first part of your makefile and I'll tell you from there. :)
#5
Woah.. You just got me mega confused.. use vi? What the? -_-

- Mozzy
#6
Okay, I did the 'vi makefile' in the src dir, and got something like;

CC = gcc
#PROF = -p
NOCRYPT =

#Uncomment the two lines beloe if compiling on a Solaris box
#SOLARIS_FLAG = -Dsun -DSYSV


And it goes on like that, finishing at


#Uncomment the line below if you want a performance increase tough beware "makefile" 73 lines, 2748 characters

So yeah, is that right? Also - how do I copy and paste outa Cygwin?

- Mozz
USA #7
Ohhh ok, you're using Cygwin. Then use your normal text editor or whatever you use to open up the source files. 'vi' is a very common/popular text editor on Unix-based systems.

You want to look for something like:
[code]
O_FILES = act_comm.o act_info.o act_obj.o \
a whole bunch of .o files
[/code]

Find that, that's where you stick in (your .c file).o according to the format shown in the file. Basically take off .c and put on .o instead.
#8
I use Microsoft Visual C++ to open the src files and edit them etc. Okay, what i did was do a big word find and found the appropiate file. (Makefile.Unix), and found all the .o's and .c files, as well as the .h files. What I did was, add in board.o, board.c and board.h (as there was one). Yet, I compile with Cygwin and it still doesn't recognis it. Whats the deal..?

- Mozz
Amended on Tue 21 Oct 2003 09:07 PM by Mozzy
USA #9
Please paste the contents of your makefile, otherwise it's impossible to tell what went wrong. :)
#10
Woot woot! Got it down. All I gota do now is put in the commands for global_boards and such. Thanks a bunch everyone, you helped me out big time. ^_^

- Mozz