Solution to running swFotE 2.0 with cygwin

Posted by Seifert on Tue 02 Aug 2005 01:27 AM — 29 posts, 97,152 views.

#0
I have found out how do to this, after about an hour.

All you have to do is go in your ~cygwin\usr\include\sys directory, and place a .h file with the following in it.



#ifndef _SYS_DIR_H_
#define _SYS_DIR_H_

#include <dirent.h>

/*
* Backwards compatibility.
*/
#define direct dirent
#define DIRSIZ(dp) _GENERIC_DIRSIZ(dp)

#endif /* !_SYS_DIR_H_ */


Theren there is an error "cannot find -ldl"

There is something wrong with the "L_FLAGS" in the makefile, and without them, you cannot move or look in the MUD, but it will still start up. If anyone has any ideas, please help me.

USA #1
It is a linking probleem. -ldl is required for dlsym support. SWFotE seems dependant on it, so I guess you better download it. I personally don't know much about it, so maybe someone else can tell you more.

Oh, and you shouldn't run anything that complains of a linker error, thats just not good practice.
USA #2
Quote:
Oh, and you shouldn't run anything that complains of a linker error, thats just not good practice.
It's actually impossible to run something that had linker errors. It's the linking phase that generates the executable and without a successful link, you have no program to run. Whatever was run was the old executable. As for being able to connect but not move or look around, that'd have to be made a bit more precise so that we can start diagnosing the problem.
USA #3
You are correct Kyilyan. I'm not sure what I was thinking.

Anyways, a new one wont work, but I'm sure the old one probably works fine besides the one problem. Dlsym is essentially the command hook, and without it you won't be able to use commands unless you download the correct files needed or simply revert back to using the functions in tables.c . In order to do that, you would have to readd all of the DECLARE_DO_FUN's, as I believe they were removed.
USA #4
Of course, if one were to want this fixed right, one could look over this part of our Makefile and adjust it as needed to fit:


afkmud: $(O_FILES)
	rm -f $(AFKMUD)
ifdef WINDOZE
	dlltool --export-all --output-def afkmud.def $(O_FILES)
	dlltool --dllname $(AFKMUD) --output-exp afkmud.exp --def afkmud.def
	$(CC) -o $(AFKMUD) $(O_FILES) afkmud.exp $(L_FLAGS)
else
	$(CC) -o $(AFKMUD) $(O_FILES) $(L_FLAGS)
endif
	echo "Done compiling mud.";
	chmod g+w $(AFKMUD)
	chmod a+x $(AFKMUD)
	chmod g+w $(O_FILES)


It shouldn't be overly difficult to figure out how to adapt that, but without the "WINDOZE" sections the dlsym code won't work in Cygwin.
USA #5
What does the .h file need to be named?
USA #6
What .h file? You need to install dlsym, or do Samson's fix.
USA #7
Hrm, know where this is downloadable? I checked The Gammon FTP and regular DL section, plus did a goodle, and got like 20 pages of gobbldy goop! sorry if these ar noob questions, but I a noob to this sorta stuff.


And does it come with instructions, hehe
Amended on Wed 26 Oct 2005 02:27 AM by Guido Sharpsword
USA #8
It's most likely a Cygwin package (if you're using it) or a separate lib. Try Googling it.
USA #9
Ok, since the google blew my mind (i'm still gonna try searching, just in case):

I don't have that text in my makefile, should I add it? it isn't AFKMUD, but FOTE (SWR, i believe, in the MAKEFILE). How can that be implemented? Again, sorry for being so annoying,
USA #10
Nevermind, I found it. I changed it to WINDOZE and it gave the same error.
USA #11
Sorry, I think I forgot to give the error:

/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -ldl
collect2: ld returned 1 exit status
make[1]: *** [swr] Error 1
make: *** [all] Error 2

Man, my head hurts! lol, And thanks for all the input. info, Zeno, yer my HERO! lol
Canada #12
These are the important line, and are out of my makefile which runs on cygwin and has dlsym working fine.

	dlltool --export-all --output-def swr.def $(O_FILES)
	dlltool --dllname $(SWR) --output-exp swr.exp --def swr.def
	$(CC)  $(W_FLAGS) -o $(SWR) $(O_FILES) swr.exp $(L_FLAGS)


You'll have to adjust it slightly. Also, where ever you have -ldl, try removing it or commenting it out. It is unnessecary in cygwin.

If this doesn't work, please post your whole make file so we can see what your seeing.
USA #13
Ok, I thought it did it, but It didn't. I couldn't get the Look and movements to work. When I tried to make the swr.exe file again it wouldn't, it got to fight.o and gave this:

fight.c:49:23: sys/dir.h: No such file or directory
make[1]: *** [o/fight.o] Error 1
make: *** [all] Error 2

What's Up with that?
Amended on Wed 26 Oct 2005 12:24 PM by Guido Sharpsword
USA #14
Here is my Makefile:

CC = gcc
PROF =
NOCRYPT =


#Uncomment if using CYGWIN to compile with
#CYGWIN_FLAG = -DCYGWIN

#Some systems need this for dynamic linking to work.
EXPORT_SYMBOLS = -export-dynamic

C_FLAGS = -g2 -Wall $(EXPORT_SYMBOLS) $(CYGWIN_FLAG) $(PROF) $(NOCRYPT) $(DBUGFLG) $(EXPORT_SYMBOLS)
L_FLAGS = $(PROF) $(EXPORT_SYMBOLS) $(CYGWIN_FLAG) $(NEED_DL) -lz -g2

#Comment out to disable cargo
USECARGO = 1

ifdef USECARGO
C_FLAGS := $(C_FLAGS) -DUSECARGO
endif


C_FILES = 11.c act_comm.c act_info.c act_move.c act_obj.c act_wiz.c boards.c \
bounty.c build.c changes.c clans.c color.c comm.c comments.c \
const.c db.c editor.c fight.c finfo.c force.c fskills.c \
functions.c handler.c hashstr.c hunter.c id.c interp.c magic.c \
makeobjs.c marriage.c md5.c misc.c mud_comm.c mud_prog.c newarena.c \
pfiles.c planets.c player.c renumber.c reset.c save.c ships.c \
shops.c skills.c slay.c slicers.c slotm.c space.c special.c \
swskills.c tables.c tech.c track.c update.c


O_FILES := $(patsubst %.c,o/%.o,$(C_FILES))

H_FILES = $(wildcard *.h)

ifdef CYGWIN_FLAG
SWR = swr.exe
COPYFILE = ../bin/cygwin/copyfile
else
SWR = swr
endif

SWR_OLD = ../bin/swr_old.exe

all:
$(MAKE) -s swr

swr : $(O_FILES)
rm -f $(SWR)

ifdef WINDOZE
dlltool --export-all --output-def ../bin/cygwin/swr.def $(O_FILES)
dlltool --dllname $(SWR) --output-exp ../bin/cygwin/swr.exp --def ../bin/cygwin/swr.def
$(CC) $(W_FLAGS) -o $(SWR) $(O_FILES) ../bin/cygwin/swr.exp $(L_FLAGS)
else
$(CC) -o $(SWR) $(O_FILES) $(L_FLAGS)
endif

echo " ";
echo "Done compiling mud.";
chmod g+w $(SWR)
chmod a+x $(SWR)
chmod g+w $(O_FILES)
ifdef CYGWIN_FLAG
./$(COPYFILE)
endif
mv $(SWR) ../bin

clean:
ifdef CYGWIN_FLAG
rm -f o/*.o ../bin/other/swr.def ../bin/cygwin/swr.exp
chmod g+w $(COPYFILE)
chmod a+x $(COPYFILE)
./$(COPYFILE)
# $(MAKE) all
else
rm -f o/*.o $(SWR_OLD) ../bin/$(SWR) ../bin/${SWR}.exe ../bin/win/swr.def ../bin/cygwin/swr.exp
# $(MAKE) all
endif


purge:
ifdef CYGWIN_FLAG
rm -f o/*.o ../bin/cygwin/swr.def ../bin/cygwin/swr.exp
else
rm -f o/*.o $(SWR_OLD) $(SWR) ../bin/cygwin/swr.def ../bin/cygwin/swr.exp
endif


o/%.o: %.c
# echo " Compiling $@....";
echo " $@";
$(CC) -c $(C_FLAGS) $< -o $@

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

USA #15
Can you show us that line in fight.c? I assume it has to do with you missing a header file.
USA #16
As soon as I get home I will, the home FTP doesn't seem to be working thru the Army's firewall. Thanks for the Patience, Zeno.
USA #17
Ok, it wouldn't let me upload, so here's the file:

http://hackshophc.com/fight.c
USA #18
#ifdef CYGWIN //CYGWIN support added by Keberus
  #include <sys/dirent.h> //Thanks Xie for the help
#else
  #include <sys/dir.h>


Looks like you forgot to enable the Cygwin flag in the Makefile.
USA #19
Where do I put that at, anywhere?
USA #20
There should be a flag in the Makefile you need to toggle on. Look in there for comments relating to Cygwin.
USA #21
Ok, I found the line that said "Uncomment this if using Cygwin" and I did, I still get the sys/dir.h error
USA #22
You shouldn't be. Make sure you edited the right file as well as doing a make clean.
USA #23
Ok, it said DONE COMPILING MUD but didn't make a .exe
USA #24
Never mind, I got it running, let's see if the MOVEMENTS work,
USA #25
DAMNIT! NONE of the commands work!!!!! Any kind of help?? I'm a lil annoyed.
USA #26
What do you mean? Like 'north' doesn't work? What happens when you try to use a command?
USA #27
Thanks for all the Help, Zeno, nice MUD you have, very Modified, lol!
USA #28
Sure, anytime. Good luck with the MUD.