Compiling on Slackware

Posted by Kanzeil on Tue 18 May 2004 05:59 AM — 7 posts, 26,533 views.

#0
:~/mud/Rom24/src$ make
gcc -c -Wall -O -g act_comm.c
gcc -c -Wall -O -g act_enter.c
gcc -c -Wall -O -g act_info.c
act_info.c: In function `do_look':
act_info.c:1122: warning: suggest explicit braces to avoid ambiguous `else'
act_info.c:1131: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g act_move.c
gcc -c -Wall -O -g act_obj.c
act_obj.c: In function `do_put':
act_obj.c:424: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c:462: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c: In function `get_cost':
act_obj.c:2481: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g act_wiz.c
gcc -c -Wall -O -g alias.c
gcc -c -Wall -O -g ban.c
gcc -c -Wall -O -g comm.c
gcc -c -Wall -O -g const.c
gcc -c -Wall -O -g db.c
gcc -c -Wall -O -g db2.c
gcc -c -Wall -O -g effects.c
gcc -c -Wall -O -g fight.c
fight.c: In function `one_hit':
fight.c:571: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g flags.c
gcc -c -Wall -O -g handler.c
handler.c: In function `reset_char':
handler.c:565: warning: suggest explicit braces to avoid ambiguous `else'
handler.c: In function `get_max_train':
handler.c:761: warning: suggest explicit braces to avoid ambiguous `else'
handler.c: In function `unequip_char':
handler.c:1644: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g healer.c
gcc -c -Wall -O -g interp.c
gcc -c -Wall -O -g note.c
gcc -c -Wall -O -g lookup.c
gcc -c -Wall -O -g magic.c
magic.c: In function `obj_cast_spell':
magic.c:643: warning: suggest explicit braces to avoid ambiguous `else'
magic.c: In function `spell_earthquake':
magic.c:2203: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g magic2.c
gcc -c -Wall -O -g music.c
gcc -c -Wall -O -g recycle.c
gcc -c -Wall -O -g save.c
gcc -c -Wall -O -g scan.c
gcc -c -Wall -O -g skills.c
gcc -c -Wall -O -g special.c
gcc -c -Wall -O -g tables.c
gcc -c -Wall -O -g update.c
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 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+0x4796): In function `do_password':
/home/operative/mud/Rom24/src/act_info.c:2722: undefined reference to `crypt'
act_info.o(.text+0x481f):/home/operative/mud/Rom24/src/act_info.c:2739: undefined reference to `crypt'
comm.o(.text+0x17c3): In function `nanny':
/home/operative/mud/Rom24/src/comm.c:1652: undefined reference to `crypt'
comm.o(.text+0x1b0e):/home/operative/mud/Rom24/src/comm.c:1764: undefined reference to `crypt'
comm.o(.text+0x1b98):/home/operative/mud/Rom24/src/comm.c:1787: undefined reference to `crypt'
collect2: ld returned 1 exit status
make: *** [rom] Error 1


Whats wrong here? Im kinda a newb to linux and compiling but what I can see is that theres something wrong in the different files themselves that is screwing with the compile if im not mistaken.. alittle help please?
USA #1
That means that you're not linking the crypt library. In other words, you don't have the right libraries loaded up, so it can't find the function it needs.

To do so, you need to add -lcrypt to your makefile. I'm surprised it's not there already: could you show me your makefile?
#2
Makefile is

CC = gcc
PROF = -O -g
NOCRYPT =
C_FLAGS = -Wall $(PROF) $(NOCRYPT)
L_FLAGS = $(PROF)

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) $<


But theres another file called Makefile.linux which has that flag in there

CC = gcc
PROF = -O -g
NOCRYPT =
C_FLAGS = -Wall $(PROF) $(NOCRYPT)
L_FLAGS = $(PROF)
LIBS = -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) $(LIBS)

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

do I gotta rename the .linux one to just Makefile and run it then?
USA #3
That's a good guess, yes. I'd try that and see if it works.
#4
Well it didnt show those crypt errors anymore..

:~/mud/Rom24/src$ make
gcc -c -Wall -O -g act_comm.c
gcc -c -Wall -O -g act_enter.c
gcc -c -Wall -O -g act_info.c
act_info.c: In function `do_look':
act_info.c:1122: warning: suggest explicit braces to avoid ambiguous `else'
act_info.c:1131: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g act_move.c
gcc -c -Wall -O -g act_obj.c
act_obj.c: In function `do_put':
act_obj.c:424: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c:462: warning: suggest explicit braces to avoid ambiguous `else'
act_obj.c: In function `get_cost':
act_obj.c:2481: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g act_wiz.c
gcc -c -Wall -O -g alias.c
gcc -c -Wall -O -g ban.c
gcc -c -Wall -O -g comm.c
gcc -c -Wall -O -g const.c
gcc -c -Wall -O -g db.c
gcc -c -Wall -O -g db2.c
gcc -c -Wall -O -g effects.c
gcc -c -Wall -O -g fight.c
fight.c: In function `one_hit':
fight.c:571: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g flags.c
gcc -c -Wall -O -g handler.c
handler.c: In function `reset_char':
handler.c:565: warning: suggest explicit braces to avoid ambiguous `else'
handler.c: In function `get_max_train':
handler.c:761: warning: suggest explicit braces to avoid ambiguous `else'
handler.c: In function `unequip_char':
handler.c:1644: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g healer.c
gcc -c -Wall -O -g interp.c
gcc -c -Wall -O -g note.c
gcc -c -Wall -O -g lookup.c
gcc -c -Wall -O -g magic.c
magic.c: In function `obj_cast_spell':
magic.c:643: warning: suggest explicit braces to avoid ambiguous `else'
magic.c: In function `spell_earthquake':
magic.c:2203: warning: suggest explicit braces to avoid ambiguous `else'
gcc -c -Wall -O -g magic2.c
gcc -c -Wall -O -g music.c
gcc -c -Wall -O -g recycle.c
gcc -c -Wall -O -g save.c
gcc -c -Wall -O -g scan.c
gcc -c -Wall -O -g skills.c
gcc -c -Wall -O -g special.c
gcc -c -Wall -O -g tables.c
gcc -c -Wall -O -g update.c
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 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 -lcrypt

but then I went into my area dir and tried to startup & and it just said

[1] 2516

nothing more.. im guessing that means i gotta fix the rest of those 'ambiguous 'else's' if not what can it be?
#5
well its actually up and running those are just minor errors that can be fixed by brushing up on abit of C++ huh? :)
USA #6
Yes, the [1] xxxx is just telling you that the job is in the background... however when you logout it might destroy the process, so you have to be careful about that. (i.e. make sure that it's still there once you've logged out.)

Those actually aren't errors, they're just caused by sloppy programming style. The compiler is warning you that the ifs and elses look ambiguous. Of course they're not ambiguous to the compiler; it's just making code style suggestions. :)