Ugh! Sorry, help please?

Posted by Saint on Sat 19 Mar 2005 02:22 AM — 10 posts, 34,110 views.

#0
Alright, I've decided to go with the Rom codebase. I've downloaded Rom24b6, and extracted the zip succesfully. However, when I run make, I also run into the following problem. Note this is not the first time either, I've run into this same exact problem on other codebases. Here it is.

comm.c: In function `main':
comm.c:421: warning: implicit declaration of function `close'
comm.c: In function `read_from_descriptor':
comm.c:1073: warning: implicit declaration of function `read'
comm.c: In function `write_to_descriptor':
comm.c:1531: warning: implicit declaration of function `write'
comm.c: In function `nanny':
comm.c:1652: warning: implicit declaration of function `crypt'
comm.c:1652: warning: passing arg 1 of `strcmp' makes pointer from integer witho
ut a cast
comm.c:1764: warning: assignment makes pointer from integer without a cast
comm.c:1787: warning: passing arg 1 of `strcmp' makes pointer from integer witho
ut a cast
gcc -c -Wall -O -g const.c
gcc -c -Wall -O -g db.c
db.c:54: error: conflicting types for `random'
/usr/include/stdlib.h:183: error: previous declaration of `random'
db.c:56: error: conflicting types for `srandom'
/usr/include/stdlib.h:184: error: previous declaration of `srandom'
make: *** [db.o] Error 1

Steven@computer ~/rom24/src
$

That silly srandom thing. I just cannot figure it out. Any help would be greatly appreciated. Thanks.
#1
Alright fixed the srandom thing. Thankfully. Hehe, but now, I run into another problem, and this one I have absolutely NO idea what to do.

Steven@computer ~/rom24/src
$ make
rm -f rom
gcc -O -g -o rom act_comm.o act_enter.o act_info.o act_move.o act_obj.o act_wiz.
o alias.o ban.o comm.o const.o db.o db2.o effects.o fight.o flags.o handler.o he
aler.o interp.o note.o lookup.o magic.o magic2.o music.o recycle.o save.o scan.o
skills.o special.o tables.o update.o
act_info.o(.text+0x501f): In function `do_password':
/home/Steven/rom24/src/act_info.c:2722: undefined reference to `_crypt'
act_info.o(.text+0x50b6):/home/Steven/rom24/src/act_info.c:2739: undefined refer
ence to `_crypt'
comm.o(.text+0x1a65): In function `nanny':
/home/Steven/rom24/src/comm.c:1652: undefined reference to `_crypt'
comm.o(.text+0x1e27):/home/Steven/rom24/src/comm.c:1764: undefined reference to
`_crypt'
comm.o(.text+0x1ebe):/home/Steven/rom24/src/comm.c:1787: undefined reference to
`_crypt'
collect2: ld returned 1 exit status
make: *** [rom] Error 1

Steven@computer ~/rom24/src
$

Grrrrrrrr...Any help guys? Please?
USA #2
Did you install the crypt lib as answered in your last topic?
#3
I did :)
USA #4
And do you have -lcrypt on your L_FLAGS ?
#5
I've tried everything you guys suggested, and still no go. Here is a copy of my makefile, and the log of what I get when I try MAKE.
---Makefile
CC = gcc
PROF = -O -g
NOCRYPT = -DNOCRYPT
C_FLAGS = -Wall $(PROF) $(NOCRYPT) -DOLD_RAND
L_FLAGS = $(PROF) -lcrypt

O_FILES = act_comm.o act_enter.o act_info.o act_move.o act_obj.o act_wiz.o \
alias.o ban.o comm.o const.o db.o db2.o effects.o fight.o flags.o \
handler.o healer.o interp.o note.o lookup.o magic.o magic2.o \
music.o recycle.o save.o scan.o skills.o special.o tables.o \
update.o

rom: $(O_FILES)
rm -f rom
$(CC) $(L_FLAGS) -o rom $(O_FILES)

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

--------------------------------------------------------
Log

magic.c: In function `spell_earthquake':
magic.c:2205: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g -DNOCRYPT -DOLD_RAND magic2.c
gcc -c -Wall -O -g -DNOCRYPT -DOLD_RAND music.c
gcc -c -Wall -O -g -DNOCRYPT -DOLD_RAND recycle.c
gcc -c -Wall -O -g -DNOCRYPT -DOLD_RAND save.c
gcc -c -Wall -O -g -DNOCRYPT -DOLD_RAND scan.c
gcc -c -Wall -O -g -DNOCRYPT -DOLD_RAND skills.c
gcc -c -Wall -O -g -DNOCRYPT -DOLD_RAND special.c
gcc -c -Wall -O -g -DNOCRYPT -DOLD_RAND tables.c
gcc -c -Wall -O -g -DNOCRYPT -DOLD_RAND update.c
rm -f rom
gcc -O -g -lcrypt -o rom act_comm.o act_enter.o act_info.o act_move.o act_obj.o
act_wiz.o alias.o ban.o comm.o const.o db.o db2.o effects.o fight.o flags.o hand
ler.o healer.o interp.o note.o lookup.o magic.o magic2.o music.o recycle.o save.
o scan.o skills.o special.o tables.o update.o
act_info.o(.text+0x4f43): In function `do_password':
/home/Steven/rom24/src/act_info.c:2732: undefined reference to `_crypt'
act_info.o(.text+0x4fda):/home/Steven/rom24/src/act_info.c:2749: undefined refer
ence to `_crypt'
collect2: ld returned 1 exit status
make: *** [rom] Error 1

Steven@computer ~/rom24/src
$
----------------------------------------------------------
Any help, again, would be much appreciated.
#6
Quote:
I've tried everything you guys suggested, and still no go. Here is a copy of my makefile, and the log of what I get when I try MAKE.


Scratch what Samson said. He had the right idea, but it is the wrong place to put it. Look here:

Quote:
$(CC) $(L_FLAGS) -o rom $(O_FILES)


Currently, the option -lcrypt is contained in the variable L_FLAGS. The problem with that is gcc requires that the library *must* come *after* the object file which needs it.

In short, place -lcrypt at the end of this line and everything should link fine.
#7
Totally Awesome! Finally, thanks to you guys, I got my rom up and running! Now I can get into the fun of porting my 17 smaug areas with over 200 rooms in each converted to run under rom! *Big toothy grin*

Special thanks to Raz, once I added that bit of code, it went well. Thanks to you all for taking the time out to offer advice, I've learned greatly from everyone. Thanks!
USA #8
Quote:

$(CC) $(L_FLAGS) -o rom $(O_FILES)


Or you could change the above to:

Quote:

$(CC) -o rom $(O_FILES) $(L_FLAGS)


And it would accomplish the same thing with -lcrypt on the L_FLAGS line.


Incidentaly, issues with crypt are why I resorted to getting the MD5 password code to work for this stuff. That way no more dealing with crypt and it's crap :)

Most folks who have actually provided feedback say they like it - especially when jumping back and forth between Cygwin and Linux pfiles.
Amended on Tue 22 Mar 2005 06:30 PM by Samson
#9
Quote:
Or you could change the above to:


$(CC) -o rom $(O_FILES) $(L_FLAGS)



And it would accomplish the same thing with -lcrypt on the L_FLAGS line.


True. However, it is probably best to do:


$(CC) $(L_FLAGS) -o rom $(O_FILES) $(LIB_FLAGS)


And add a variable called LIB_FLAGS with all the libraries that you wish to include. It seems that gcc has a weird system of parsing the flags as it goes left to right, so an option might not be turned on until it is read on the command line.

Quote:
Incidentaly, issues with crypt are why I resorted to getting the MD5 password code to work for this stuff. That way no more dealing with crypt and it's crap :)


That was probably a good choice for another reason. You would have left Windows systems out of the loop since they do not have a similar function AFAIK. Packing a custom algorithm with IMC was a good idea in the long-run for maintaing and porting the code.