SWR compile problem, crypt and trunc

Posted by Jobey5000 on Wed 12 May 2004 03:34 AM — 10 posts, 29,699 views.

#0
first off id like to say that even though this is my first post, this form has helped me alot, i like to make sure my question hasent already been answered befor i post, thanks guys

following is cygwin output, (wow, hey look at that i got all the way to my fisrt make without posting a question, and i only had to download 5 times!)

$ make
make swrip
make[1]: Entering directory `/home/src'
gcc -c -g3 -Wall -DREQUESTS act_wiz.c
In file included from mud.h:264,
from act_wiz.c:32:
alias.h:39:98: warning: no newline at end of file
act_wiz.c:1838: error: conflicting types for `trunc'
/usr/include/math.h:144: error: previous declaration of `trunc'
act_wiz.c: In function `do_form_password':
act_wiz.c:4976: warning: implicit declaration of function `crypt'
make[1]: *** [act_wiz.o] Error 1
make[1]: Leaving directory `/home/src'
make: *** [all] Error 2
$ qdb
BASH: qdb: command not found
$

this is line 1838 of act_wiz.c


void trunc(char *s, int len)
{
if ( strlen(s) > len )
s[len] = '\0';
}


this the function the crypt error is in


/* Online high level immortal command for displaying what the encryption
* of a name/password would be, taking in 2 arguments - the name and the
* password - can still only change the password if you have access to
* pfiles and the correct password
*/
void do_form_password( CHAR_DATA *ch, char *argument)
{
char arg[MAX_STRING_LENGTH];

argument = one_argument(argument, arg);

ch_printf(ch, "Those two arguments encrypted would result in: %s",
crypt(arg, argument)); //this is line 4976
return;
}


my makefile looks like this...


CC = gcc
PROF =
NOCRYPT =
#Uncomment the next line if you want request support
DBUGFLG = -DREQUESTS
C_FLAGS = -g3 -Wall $(PROF) $(NOCRYPT) $(DBUGFLG)
L_FLAGS = $(PROF) -lcrypt

O_FILES = act_comm.o act_info.o act_move.o act_obj.o act_wiz.o boards.o \
build.o clans.o comm.o comments.o const.o db.o fight.o \
handler.o hashstr.o id.o interp.o magic.o makeobjs.o \
misc.o mud_comm.o mud_prog.o newarena.o player.o requests.o \
reset.o save.o shops.o skills.o special.o tables.o track.o update.o \
space.o space2.o bounty.o swskills.o alias.o grub.o mapper.o

C_FILES = act_comm.c act_info.c act_move.c act_obj.c act_wiz.c boards.c \
build.c clans.c comm.c comments.c const.c db.c fight.c \
handler.c hashstr.c id.c interp.c magic.c makeobjs.c \
misc.c mud_comm.c mud_prog.c newarena.c player.c requests.c \
reset.c save.c shops.c skills.c special.c tables.c track.c update.c \
space.c space2.c bounty.c swskills.c alias.c grub.c mapper.c

H_FILES = mud.h bet.h

all:
# co $(H_FILES)
make swrip
# rm -f $(H_FILES)
mv swrip ../bin/swrip

swrip: $(O_FILES)
rm -f swrip
$(CC) $(L_FLAGS) -o swrip $(O_FILES) -lm
chmod g+w swrip
chmod g+w $(O_FILES)

.c.o: mud.h
$(CC) -c $(C_FLAGS) $<

clean:
rm -f $(O_FILES)


any ideas?
USA #1
Don't know about trunc, but don't you have to add -DNOCRYPT to your NOCRYPT line in the makefile?

Do a search for "crypt" in mud.h and see what you find, that should tell you what exactly you need to define.
#2
Thanks, one down one to go.. so far..

cygwin now outputs this:

$ make
make swrip
make[1]: Entering directory `/home/src'
gcc -c -g3 -Wall -DNOCRYPT -DREQUESTS act_wiz.c
In file included from mud.h:264,
from act_wiz.c:32:
alias.h:39:98: warning: no newline at end of file
act_wiz.c:1838: error: conflicting types for `trunc'
/usr/include/math.h:144: error: previous declaration of `trunc'
make[1]: *** [act_wiz.o] Error 1
make[1]: Leaving directory `/home/src'
make: *** [all] Error 2
$


and this was supposed to be F.U.S.S.

(p.s. Nick Gammon, id pay money for you to be a coder on my staff.)
Canada #3
Heh, good luck with that last bit.

Anyways, I just downloaded the SWR1FUSS.tgz file available in Nick's download section, and it compiled almost cleanly. However, never saw that problem that you have. I did a grep in my src directory, and here is what I got
Quote:
$ grep trunc *.c
i3.c: * Returns strlen(src); if retval >= siz, truncation occurred.
i3.c: * truncation occurred.
imc.c: * Returns strlen(src); if retval >= siz, truncation occurred.
imc.c: * truncation occurred.
$
I assume that you added the trunc function your self? It looks like your using it to keep the size of string under control. If thats the case you could use snprintf/strncat/strncpy to do this. Just remember that these do NOT null the end string, if you have it, use strlcpy/strlcat, much better function.

Either way, looks like you just happen to be infringing on a math function name, if you want to keep it, just rename the functionm should cure all your problem.

P.S.
Quote:
and this was supposed to be F.U.S.S.
The fuss packages work fine when they are released, but when you modify it, its not going to stay fixed up nessecarily. Not refering to you specifically, but it looks like a few people seem to have this misconception about the ability and extent of the fuss code.
Amended on Wed 12 May 2004 06:07 AM by Greven
#4
Well, This isent SWR FUSS. Its SWRiP, a verry long lived and highly edited game, i got the download from swrip.betterbox.net i think its in the information page.

SWRIP has many things SWR dose not.

also, i have the binary for the basic FUSS SWR, it loads up in dos but is not complatible with SWRiP files. Thats ok, but when i try to gcc the same file in cygwin i got a popup error:

The CYGICONV-2.DLL file is linked to missing export CYGWIN1.DLL:_mb_cur_max

i hope this is just becase its a dos binary...

i looked in Math.h on line 144

extern double trunc _PARAMS((double));

i dont know what this is supposed to do... can i comment this out in math.h without having major problems?
Canada #5
No, you do not want to touch any of the system directories. If your using SWRip why did you say it was fuss? Either way, they probably never compiled it on cygwin. You will have to change the trunc function within the code, not the library ones. As to the other error form windows, I got the same thing when running it, just do a windows search for the file, it should be in /cygwin/bin, and copy it into the directory your .exe file is being ran from, same with cygwin1.dll, I think.
Amended on Wed 12 May 2004 06:10 AM by Greven
USA #6
Don't touch math.h. Very, Very, VERY bad idea.

Figure out what it's doing in the code, and either make a work-around or comment it out if it's not necessary.

Quote:
Thats ok, but when i try to gcc the same file in cygwin i got a popup error:

What does "gccing a file" mean?
#7

i changed it all to trunc1, making a clean compile now, all fixxed.

ksilyan: you use make to compile, then use the gcc command to run the program you just compiled..

as for cygwin1.dll it is was in the directory of the application, but cygiconv-2.dll .. do they both need to be in the directory of the app?

bah, a directory bug in fight.c ... im halfway there baby!
USA #8
Heh. I know exactly what gcc does. Gcc is a *compiler*, it doesn't run programs. What you are saying is just not making any sense. Makefiles don't compile things. Makefiles organize your compiling process, and are used to tell gcc what to compile.
USA #9
Lets clarify. gcc is the compiler called from the Makefile when you use the command make. Make is simply the command that compiles the program to the specifications set within the makefile, as well as the files included.

Anyways, I guess I'm a little confused. You are trying to run SWRiP on a Windows box? Was it ported for that? Or are you just trying to compile it on your own computer without having to log into the shell and the like?

Also, what other errors besides the cygwin pop are you having? You mentioned a "directory" error within fight.c.