QuickMud/Cygwin Compile Error

Posted by Di0r on Sat 01 Mar 2008 11:15 PM — 4 posts, 22,690 views.

#0
Alright, so, I was interested in getting ROM again to play with, so I checked out QuickMUD, thought it sounded snazzy, downloaded it, got cygwin, downloaded the required stuff from devel (make, gcc and all that good stuff). I'm using the Makefile provided in what I assume is the most recent version of QuickMUD here: http://www.mudbytes.net/index.php?a=files&cid=259

However, when I do a make on the src folder, I get this error:


$ make
gcc -O -g3 -Wall -DIMC -DUMCROM -c -o obj/db.o db.c
db.c:56: error: conflicting types for 'random'
/usr/include/cygwin/stdlib.h:27:error: previous declaration of 'random' was here
db.c:56: error: conflicting types for 'random'
/usr/include/cygwin/stdlib.h:27:error: previous declaration of 'random' was here
db.c:60: error: conflicting types for 'srandom'
/usr/include/cygwin/stdlib.h:28:error: previous declaration of 'srandom' was here
db.c:60: error: conflicting types for 'srandom'
/usr/include/cygwin/stdlib.h:28:error: previous declaration of 'srandom' was here
make: *** [obj/db.o] Error 1


This is the makefile:


# $Id $

# Makefile for Rom24. Works fine on my Debian system.
# You may need to use 'gmake' on BSD systems.

CC = gcc
RM = rm
EXE = rom
PROF = -O -g3

C_FLAGS = $(PROF) -Wall
L_FLAGS = $(PROF) -lcrypt

#IMC2 - Comment out to disable IMC2 support
IMC = 1

ifdef IMC
   C_FLAGS := $(C_FLAGS) -DIMC -DIMCROM
endif

# Source Files
SRC_FILES := $(wildcard *.c)

# Object Files
OBJ_DIR = obj
OBJ_FILES := $(patsubst %.c,$(OBJ_DIR)/%.o,$(SRC_FILES))

rom: $(OBJ_FILES)
	$(RM) -f $(EXE)
	$(CC) -o $(EXE) $(OBJ_FILES) $(L_FLAGS)

$(OBJ_DIR)/%.o: %.c
	$(CC) $(C_FLAGS) -c -o $@ $<

clean:
	$(RM) -f $(OBJ_FILES) $(EXE) *~ *.bak *.orig *.rej

distro:
	make clean
	cd ../..
	$(RM) -f log/*.log
	tar zvcf quickmud-`date -I`.tar.gz QuickMUD


Any help would be greatly appreciated.
Amended on Sun 02 Mar 2008 01:51 AM by Di0r
Australia Forum Administrator #1
The definition in stdlib.h is this:


int random (void);


What do you have for "random" in line 56 of db.c?
#2
Line 56 has:

long random ();


EDIT: Whoops, my bad. The previous log in the first post should've read "srandom", and not "random" like it did. I've went back to the OP and changed it. Sorry about that.

EDIT2: Alright, I changed line 56 of db.c to int random (void), and changed 60 to long srandom(unsigned). It looks like the declarations were just funky. Cheers, Nick.

Amended on Sun 02 Mar 2008 01:57 AM by Di0r
USA #3
You don't really need to declare random() yourself at all if the standard libraries have done that for you. Makes for less confusion and weird errors.