Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Home Town 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Alkarindil
Brazil (70 posts) Bio
|
Date
| Sat 09 Jun 2007 02:53 AM (UTC) |
Message
| Hej!
I am making a town's option to my mud.
So, we have a "../hometowns/" folder, a "town.lst" file and the towns files.
I just used the same lines we use to the races.
So, I can make some races illegal to some towns.
I've made an option on the register of a new character, etc.
But I get 5 errors that I don't know where to fix.
Can anybody help-me in this please?
It's almost the same code of races, but with another variable names, etc.. If we replace the "race"s with "town"s, that's almost what I have here.
The compiler returns me this:
----------------------
Compiling...
tables.c
Linking...
comm.obj : error LNK2001: unresolved external symbol _town_table
tables.obj : error LNK2001: unresolved external symbol _town_table
comm.obj : error LNK2001: unresolved external symbol _MAX_PC_TOWN
tables.obj : error LNK2001: unresolved external symbol _MAX_PC_TOWN
smaug.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
smaug.exe - 5 error(s), 0 warning(s)
---------------------- | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sat 09 Jun 2007 04:52 AM (UTC) |
Message
| What file is town_table in? It sounds like, whatever that file is, you haven't added it to the list of files to be linked in the Makefile. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Alkarindil
Brazil (70 posts) Bio
|
Date
| Reply #2 on Sat 09 Jun 2007 06:09 AM (UTC) |
Message
| It must be a race_table copy. Where is race_table?
hard life... | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #3 on Sat 09 Jun 2007 07:07 AM (UTC) |
Message
| |
Posted by
| Alkarindil
Brazil (70 posts) Bio
|
Date
| Reply #4 on Mon 11 Jun 2007 11:25 PM (UTC) |
Message
| Ok.. I saw the page. And I downloaded some linux here, I will try to transfer everything to the other system.. =D
But I still with the same error. I asked some friends for some help, but nothing...
Do u have another tip?
thanks! | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #5 on Tue 12 Jun 2007 12:32 AM (UTC) |
Message
| You have an undefined symbol town_table, according to the error message.
You need to work out what file that is in, and make sure it is linked as part of the linking phase. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #6 on Tue 12 Jun 2007 12:38 PM (UTC) |
Message
| Alkarindil, I am looking over the Smaug hometown snippet and I see nothing about town_table in it. What exactly are you putting in? |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Alkarindil
Brazil (70 posts) Bio
|
Date
| Reply #7 on Tue 12 Jun 2007 03:45 PM (UTC) Amended on Tue 12 Jun 2007 05:35 PM (UTC) by Alkarindil
|
Message
| Ok.
I will make an example. This is what I am trying to do:
//-----
MUD: Smaug MUD blablabla
Type your name, or type 'new':
Client: new
MUD:Choose a name:
Client: Bilbo
MUD: Bilbo, I get it? [Y/N]
Client: Y
MUD: Choose a password
Client 12345
MUD: Again..
Client: 12345
MUD: Your sex [M/F]
Client: M
MUD: Choose a class: [thief, warrior, ranger]
Client: thief
MUD: Choose a race: [hobbit, human, orc]
//First: an elf here cannot be a thief, alright?
Client: hobbit
MUD: Choose a hometown: [Bree, Hobbiton]
//Second: a hobbit cannot start the game in Mordor.
Client: Bree
MUD: RIP, ANSI or none of then? [A/R/N]
Client: ANSI
MUD: Well done, have a good game, welcome, blablabla...
//-----
I am not using that crimson blade's code, because it seems to doesn't work this way.
Sooo, I **duplicated** some parts of **race's code**, so I can use .town files with restrictions to some races, exactly the way we have classes restrictions in the race's code!
I want a minas_tirith.town file just like this:
---
Name Minas Tirith~
Town 0
Races 14
Language 0
Town_Recall 30000
End
--
Where:
Name: The name.
Town: The town in the smaug code array.
Races: Race restriction. Example: Orcs.
Language: The town's language from the code array.
Town_recall: The room whe can return after death, inside the respective town.
I don't want nations, nor leaders or descriptions. Just hometowns with a race restriction.
It's a test, by now. I am trying to make it work, but I am not understanding why this error ("unresolved external symbol") keep coming!
What kind of files are you talking about? The .c files?
How the hell can I define this damn symbol? I just have two race codes, with different names, different variables. Except the skill's thing. I changed the race's functions to fit the new town's code.
That's it.
Thanks. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #8 on Tue 12 Jun 2007 11:07 PM (UTC) |
Message
| I think you need to read a little about C tutorials and what that error message means. You should try googling the error, too. It's actually an extremely simple error to fix.
What it's telling you is that you made reference to a variable that does not exist. You told the compiler it exists, e.g. using an "extern (var type) (var name)" statement but then you failed to actually create it, by using a "(var type) (var name)" statement.
Try it out; in some .c file, write down
extern int silly_variable;
then in a function in the same .c file, say
silly_variable = 3;
and compile, you will get a "unresolved external symbol" error.
Now if you go to another .c file and you write:
int silly_variable;
it will start working. Simple as that... |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Alkarindil
Brazil (70 posts) Bio
|
Date
| Reply #9 on Wed 13 Jun 2007 10:07 PM (UTC) Amended on Wed 13 Jun 2007 10:08 PM (UTC) by Alkarindil
|
Message
| David:
You are right!
Horever, deleting the "extern" thing, now I can't list the towns in the registration screen.
Just to remember: it works the same way as races code.
I have only one ".town" file and a "towns.lst" file in a "hometowns/" folder.
I think that maybe it can't list the town's content because of this "extern"'s missing. I don't know...
I am looking for more information, if it work fine, I'll bring the code to the forum.
thanks! | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #10 on Wed 13 Jun 2007 10:18 PM (UTC) |
Message
| Like I said, I think it would really save you some grief to learn about what these error messages mean. To give you a quick summary, in C(++), a variable always needs to be declared before you can use it. Declaring a variable is telling the compiler that it exists. One way to declare a variable is to define it, e.g. int foo; . That actually creates the physical variable "foo", of type "int".
Another way to declare an integer is to tell the compiler that it exists somewhere else. That is what extern is for: extern int foo; . This tells the compiler that, somewhere else, you have created the physical space for the variable.
The reason you need to use extern is that you don't want several physical copies of a variable. (In fact, the compiler won't let you.) So, you define it in one file by saying "int foo" and in other files, when you want to use it, you say "extern int foo".
But, again, I cannot stress enough how important it would be for you to read up on this properly. Even if it annoys the hell out of you now and you think it's a waste of time, you will gain very, very much in the long run and will be able to solve your problems on your own quickly. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Alkarindil
Brazil (70 posts) Bio
|
Date
| Reply #11 on Thu 14 Jun 2007 12:04 AM (UTC) |
Message
| Alright, I understood.
The line with that problem is:
"extern struct town_type * town_table [MAX_TOWN];"
it's a copy of
"extern struct race_type * race_table [MAX_RACE];"
in mud.h.
The problem to understand it is no more. Now I want to know where is the original race's variable to know if there is some possibility of making a town's similar variable.
I believe it is inside two functions I did not used for town's code. I think I must understand if a c function kills the variable declared inside or not, so I can discover where it is.
Horever, thanks again. I'll keep those things in mind. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #12 on Thu 14 Jun 2007 12:10 AM (UTC) |
Message
| I think that race_table is defined in const.c. If you are in a Unix-like environment, try:
grep race_table *.c
that will show you every place that "race_table" appears in the code. It will let you find where race_table is defined. Then you can put your town_table definition in the same place. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
31,125 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top