Register forum user name Search FAQ

Gammon Forum

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 ➜ ROM ➜ Running the server ➜ unresolved external symbol (dirent.h)

unresolved external symbol (dirent.h)

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by ShadowFangs   (3 posts)  Bio
Date Sun 03 Oct 2004 03:15 AM (UTC)
Message
Hey all, Using MSVC 6.0

I read that An unresolved external means that you have called a function or variable but that the function or variable is not defined in the code linked to the executable.

these are the errors.
error LNK2001: unresolved external symbol _closedir
error LNK2001: unresolved external symbol _readdir
error LNK2001: unresolved external symbol _opendir

Great, so that means that this function wont work.

void do_plist(CHAR_DATA *ch, char *argument)
{
DESCRIPTOR_DATA *d;
BUFFER *pbuf;
struct dirent *Dir;
DIR *Directory;
char FName[80];
char buf[MSL];
int nMatch, neat1;
char neat[MSL];
char neat2[MSL];
char neat3[MSL];

nMatch = 0;

pbuf = new_buf();
d = new_descriptor();
Directory = opendir( PLAYER_DIR );
Dir = readdir( Directory );
send_to_char("{C PLAYER BASE {x\n\r",ch);
send_to_char("{RName lvl Race Class {x\n\r",ch);
send_to_char("{R==============================================={x\n\r",ch);
while( Dir != NULL )
{
sprintf(FName, PLAYER_DIR "%s", Dir->d_name);
{
if (Dir->d_name[0] >= 'A' && Dir->d_name[0] <= 'Z')
{
nMatch++;
load_char_obj( d, Dir->d_name );
if ( d->character->level <= ML )
{
sprintf(neat, "%s", Dir->d_name);
neat1 = d->character->level;
sprintf(neat2,"%s", capitalize(race_table[d->character->race].name));
sprintf(neat3,"%s", capitalize(class_table[d->character->class].name));


sprintf(buf, "{B[{c%-12s{B][{c%-2d {B][{c%-10s {B][{c%-12s {B]{x\n\r",
neat, neat1, neat2, neat3);
add_buf(pbuf, buf);
}
}
}
Dir = readdir( Directory );
}
closedir( Directory );
page_to_char(buf_string(pbuf), ch);
free_buf(pbuf);
sprintf( buf, "\n\r{cPlayers found{C: {Y%d{x\n\r", nMatch );
send_to_char( buf, ch );
return;
}

Any suggestions?

Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #1 on Sun 03 Oct 2004 05:20 AM (UTC)
Message
Yeah, a little searching on google, looks like they functions are just not in MSVC. I did read something that said you can try to use some defines, like
    #ifdef MSVC 
    #define open _open 
    #define O_RDONLY _O_RDONLY 
    #define fstat fstat 
    #define S_ISREG(m) ((m)&_S_IFREG) 
    #endif
This comes from http://www.cs.mu.oz.au/research/mercury/mailing-lists/mercury-users/mercury-users.0105/0076.html, that might help.

I also found this:
Quote:
One of the least standard aspects of libc is how to read what files are contained in a directory. Most DOS and Windows compilers have some kind of findfirst() and findnext() functions, but they differ as to exactly what these are called and what parameters they take. Posix systems (Unix, djgpp) have opendir() and readdir(), but these are missing from MSVC. So either don't do such things, or use the Allegro for_each_file() function, which is supported on all platforms.


I do not have MSVC myself, though, so I can't confirm any of this.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by ShadowFangs   (3 posts)  Bio
Date Reply #2 on Sun 03 Oct 2004 11:13 PM (UTC)
Message
Well, this being known now, is there any other way to do what i want this function to do? Any help is appreciated, thanks
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #3 on Sun 03 Oct 2004 11:55 PM (UTC)
Message
Well, one option is to forget MSVC and try something like cygwin. Its free and tends to work fairly well. This - http://msdn.microsoft.com/library/en-us/dnucmg/html/ucmglp.asp - may also be of some help.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #4 on Mon 04 Oct 2004 01:32 AM (UTC)

Amended on Mon 04 Oct 2004 01:34 AM (UTC) by Meerclar

Message
Another option is to search the forum for dirent and copy the info Nick provided me a while back into a header file for your MSVC project.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #5 on Wed 06 Oct 2004 06:49 AM (UTC)
Message
I did a simulation of the dirent stuff. It is in the SMAUG port.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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,400 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.