compiling under Cygnus

Posted by Translucent Hate on Mon 12 Mar 2001 07:37 AM — 34 posts, 127,551 views.

USA #0
i'm using the smaug1.4 win32 port that you created,
but i can't seem to compile it under cygnus...
you asked to post it here so i did, i'm not too sure
what is causing the problem, but i'm sure its a
simple change in the code.
Australia Forum Administrator #1
To compile under Cygnus, you don't need the Win32 port, as the Cygnus compiler effectively emulates the Unix operating system.

I got it to compile and run using the following steps:

Download the source

Get the source from:

ftp://ftpgame.org/pub/mud/diku/merc/smaug/smaug1.4a.tgz




Create directory


mkdir smaug
cd smaug

Unpack source

tar xvzf smaug1.4a.tgz

Change to source directory

cd dist/src

Amend source as follows

In mud.h:

#define NOCRYPT // <--- add this because we don't have crypt

In interp.c:

#define __rtems__ // <--- Add this
#include <time.h> // <--- before this line

In acct_comm.c, right near the end:

int is_profane (char *what)
{
#if 0 // <--- change from #ifndef WIN32 to #if 0
int ret;

ret = re_exec(what);
if (ret==1)
return(1);
#endif
return(0);
}

Compile source

make

If you get an access violation, try just typing 'make' again.

Change to 'area' directory

cd ../area

Run the server

../src/smaug.exe



All done!


Amended on Tue 20 Nov 2007 04:23 AM by Nick Gammon
USA #2
i've been checking out other code bases as well...
is it going to be pretty much the same changes
using cygnus or alot different? for example...
rom24b6 i've been looking into and also the
rogue code base... i'm pretty sure those would
have similiar changes but not positive...

thanks for the info though.
Australia Forum Administrator #3
These are pretty minor changes, so I imagine the others will be similar.

If you have problems, say with ROM, then post a message in the ROM part of the forum.
USA #4
i will do that... definately... cause i'm sure
others are doing it this way as well...

here's the deal with the smaug... i downloaded that
gzip from the ftp site, made the changed you specified
and still came up with errors... have you found a
way to log in cygnus cause the only way i can log is
the old print screen deal...

the screen is at
http://www.ultranet.com/~jjmartin/errors/error.jpg
it'll take a bit to come up but thats the error...
wish i could cut and paste the text...
Australia Forum Administrator #5
Keeping a log

The simple way of keeping a log is to redirect stdout and stderr, like this:


 make &> mylog.txt

This will put everything into "mylog.txt".

If you want to watch on the screen as well, use a variant:


make 2>&1 | tee mylog.txt

Copying text from the screen

Another useful trick to know is how to pull text out of a "dos" window. To do this click on the "edit" button: Edit icon - 1K

Then, click and drag with the mouse until the desired text is highlighted. Then press <enter> on the keyboard, and the selected text will be copied to the clipboard.


This error message

Your jpg image gave an error message similar to this:


gcc -c  -O -g3 -Wall -Wuninitialized    -DSMAUG     interp.c
interp.c: In function `interpret':
interp.c:758: warning: int format, long int arg (arg 7)
interp.c:758: warning: int format, long int arg (arg 8)
interp.c: In function `update_userec':
interp.c:1192: warning: implicit declaration of function `timerisset'
interp.c:1193: warning: implicit declaration of function `timercmp'
interp.c:1193: parse error before `<'
interp.c: At top level:
interp.c:1198: parse error before `if'
make[1]: *** [interp.o] Error 1
make[1]: Leaving directory `/home/nick/smaug/dist/src'
make: *** [all] Error 2

I got this before I made the change that I recommended to the file interp.c. Did you do that?


#define __rtems__ // <--- Add this 
#include <time.h> // <--- before this line 

It might not be obvious, but that is two underscores on each side of the word "rtems".

Amended on Mon 12 Mar 2001 09:47 PM by Nick Gammon
USA #6
well my first problem was

#if 0 // <--- change from #ifndef WIN32 to #if 0

i actually only changed WIN32 to 0 i didn't delete
the ndef, which cleared up most of the errors...
also in interp.c i found the lines that those
errors occurred on and saw the end of the lines
looking like this , <)
and i said "hey.. lets try this for kicks" and removed
the , and the < and it went through all the files no
problem but then got a big long error list... guess
that was bad. ;)

and yeah... i cut and pasted the text, so it know that
i have __rtems__

but when i move that above time.h i get more errors...
maybe there is something else i'm missing that needs a
change because right now it should be working cause i
have changed exactly what you did.
Australia Forum Administrator #7
Hmmm - removing lines that give you errors is only a short-term solution. :)

Can you email me your copy of interp.c? I would like to try it myself.

And please include the exact error messages using the technique I described for saving them to a text file. Saying "I got more errors" doesn't help me solve the problem.
USA #8
well basically the error i get is exactly the same
as the way you posted it in your last message, that
is why i didn't post the error... and on my last message
i thought i added asking you if you wanted to look
at the interp.c that i have... and i actually put
it up on my site.

http://www.ultranet.com/~jjmartin/errors/interp.c

it just seems odd that we are doing the exact same
changes with different results... but then again
its almost 2am here...
Australia Forum Administrator #9
This is how the start of your file is:



#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "mud.h"
#ifdef USE_IMC
#include "icec-mercbase.h"
#define __rtems__
#endif




My instructions said to put "#define __rtems__" before "#include <time.h>", which you have not done. It is essential that they be in the right order, because the file "time.h" checks to see if __rtems__ is defined, and if so, creates "timercmp" and "timerisset".

Try it like this:



#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#define __rtems__
#include <time.h>
#include "mud.h"
#ifdef USE_IMC
#include "icec-mercbase.h"
#endif




Australia Forum Administrator #10
I have had a query from someone else (who is not familiar with Unix commands) about how to do the steps I outlined above.


The basic steps I took were:


Create the directory

Using the Unix shell (ie. after running cygwin.bat) create a subdirectory:


mkdir smaug


Change to this directory

cd smaug

Copy the archive into that directory

Exactly how you do this depends on where you downloaded the smaug archive to. Assuming you put it into C:\SMAUG, do this:


cp c:/smaug/smaug1.4a.tgz .


Note the trailing dot.

Unzip the archive


tar xvzf smaug1.4a.tgz


Check the results

By doing a "ls" (list directory) you should see the following:


dist ftp_game.org smaug1.4a.tgz


"Dist" is a directory (it stands for "distribution").

For more detail, do an "ls -l", like this:



$ ls -l
total 772
drwxr-xr-x  20 nick     None         4096 May 28  1999 dist
-rw-r--r--   1 nick     None         1106 Oct 16  1997 ftp_game.org
-rw-r--r--   1 nick     None      1575821 Mar 17  2000 smaug1.4a.tgz



Do the other steps

Now you can do the other steps I described above.

I would edit the files and make the suggested changes using any text editor that supports Unix-style text files (eg. UltraEdit).

Then:


cd dist/src
make
cd ../area
../src/smaug.exe


Amended on Tue 13 Mar 2001 01:00 AM by Nick Gammon
USA #11
ok... finally got it running, but this is what is
interesting...

the first time i made the changes i actually put the
__rtems__ before time.h in interp.c but that wasn't
even the problem... the problem was that the mud was
in c:\smaug\dist\src and now its locate in the dir
c:\cygwin\home\laptop\smaug\dist\src and everything
is peachy.. so i guess the problem is that is doesn't
like being in a directory not in cygwin.

thanks for the help... i'm going to post on the rom
board the problem with the rom later on, but i'm more
wanting to check out rogue codebase, but i'm not sure
if you are even familiar with that, but i think i might
just stick with smaug and/or rom cause those are what
i am familiar with.
Australia Forum Administrator #12
Yes, I was a bit surprised when I saw from your error message that you didn't seem to have it under

/home/yourname

... but I just assumed you had found a way to do it.

For the record, my directory structure was:


home
|
nick
|
smaug
|
dist
|
src


This was all under the Cygwin directory, so effectively all of the above were under, in my case:


d:\cygwin


So, from Windows' point of view, the source was in:


d:\cygwin\home\nick\smaug\dist\src




Amended on Tue 13 Mar 2001 12:38 PM by Nick Gammon
#13
I'm trying to compile using Cygwin and I followed your steps but I keep getting the following:
make smaug
make[1]: Entering directory `/cygdrive/c/cygwin/home/acgregory/smaug/dist/src'
rm -f smaug
gcc -o smaug 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 deity.o fight.o handler.o hashstr.o ibuild.o ident.o interp.o magic.o makeobjs.o mapout.o misc.o mpxset.o mud_comm.o mud_prog.o player.o polymorph.o requests.o reset.o save.o shops.o skills.o special.o tables.o track.o update.o grub.o stat_obj.o ban.o services.o planes.o imm_host.o colorize.o
act_info.o(.text+0xb212): undefined reference to `crypt'
act_wiz.o(.text+0x12670): undefined reference to `crypt'
build.o(.text+0x67a1): undefined reference to `crypt'
comm.o(.text+0x3b20): undefined reference to `crypt'
comm.o(.text+0x3ddb): undefined reference to `crypt'
comm.o(.text+0x3ebc): more undefined references to `crypt' follow
collect2: ld returned 1 exit status
make[1]: *** [smaug] Error 1
make[1]: Leaving directory `/cygdrive/c/cygwin/home/acgregory/smaug/dist/src'
make: *** [all] Error 2

Australia Forum Administrator #14
Sounds like you didn't have the define for NOCRYPT.

Alternatively, in the Makefile, add the option -DNOCRYPT to the line that does the compile.
#15
At the risk of sounding like an airhead...
Where exactly do I put the #Define NOCRYPT in mud.h? I put it in there befroe I ever tried to compile it.
Also -Dnocrypt doesn't seem to work.
Australia Forum Administrator #16
Pretty-well anywhere (eg. near the start). It is:


#define NOCRYPT


not #Define.


As for the makefile, I don't have it on me right now, but the changes would look like this (lifted from the forum section about recompiling ROM).


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

#17
Ok, I put it at the beginning of mud.h as #define NOCRYPT and in the makefile as you said but I still get those errors.
Australia Forum Administrator #18
You might need to force a recompile. Do:


rm *.o


and then:


make

USA #19
if you have the newest version of cygwin(and by that i mean you downloaded the setup.exe) then you have the crypt.h file. all you need to do is add #include <crypt.h> to the top of those files that gave you errors, with the other includes. then in your makefile add -lcrypt to the line that says this, $(CC) $(L_FLAGS) $(USE_IMC) -g -o smaug.exe $(O_FILES) -lcrypt. now you have encrypted passwords.
#20
Hi,

Attempting to compile smaug1.4a under Win98/CygnusB19 and getting many errors re: files not found (comm.c 60 -> netinit/in_systm.h). I'm assuming that perhaps this should be commented out like regex references?

Is there a full-blown detailed list of what should be modified/deleted for successful compiling? It was by chance I read about the regex references. TIA!
Australia Forum Administrator #21
The second post on this subject (page 1) is the complete list.

I had not commented out the line about:


#include <netinet/in_systm.h>


I can only assume that your Cygwin installation is somehow incomplete.

Personally I installed everything, perhaps you left bits out (of Cygwin).




#22
Thanks for the reply Nick. Everything compiles, up to interp.c then I get:

interp.c: In function `update_userec':
interp.c:1192: warning: implicit declaration of function `timerisset'
interp.c:1192: warning: implicit declaration of function `timercmp'
interp.c:1192: parse error before `<'
interp.c: At top level:
interp.c:1197: parse error before `if'
make[1]: *** [interp.o] Error 1
make: *** [all] Error 2

which is:

void update_userec(struct timeval *time_used, struct timerset *userec)
{
userec->num_uses++;
if ( !timerisset(&userec->min_time) || timercmp(time_used, &userec->min_time, <) >
{
userec->min_time.tv_sec = time_used->tv_sec;
userec->min_time.tv_usec = time_used->tv_usec;
}
if ( !timerisset(&userec->max_time) || timercmp(time_used, &userec->max_time, >) >
{
userec->max_time.tv_sec = time_used->tv_sec;
userec->max_time.tv_usec = time_used->tv_usec;
}
userec->total_time.tv_sec += time_used->tv_sec;
userec->total_time.tv_usec += time_used->tv_usec;
while ( userec->total_time.tv_usec >= 1000000 )
{
userec->total_time.tv_sec++;
userec->total_time.tv_usec -= 1000000;
}
return;
}

I do have:
...
#define __rtems__
#include <time.h>
...

and I'm almost positive I installed the complete Cygnus B19 and I use the cygnus.bat to get the shell running.
Again, any help most appreciated.

-7om
#23
Hi,

Well, I grabbed the latest Cygnus (setup.exe and installed it). Everything compiled ok (smaug1.4a). After a make clean/make smaug everything came out fine. Thanks to all for the feedback! Now, is it possible to create a smaug.exe that doesn't require the cygwin1.dll? Just curious. Thanks again.
Amended on Mon 23 Apr 2001 10:58 PM by Cylent
Australia Forum Administrator #24
May as well copy and paste the relevant macros into mud.h or the top of the source file that is causing the problems. That should fix it (the brute-force way) ...



/* Convenience macros for operations on timevals.
   NOTE: `timercmp' does not work for >= or <=.  */
#define timerisset(tvp)   ((tvp)->tv_sec || (tvp)->tv_usec)
#define timerclear(tvp)   ((tvp)->tv_sec = (tvp)->tv_usec = 0)
#define timercmp(a, b, CMP)                   \
  (((a)->tv_sec == (b)->tv_sec) ?                 \
   ((a)->tv_usec CMP (b)->tv_usec) :                \
   ((a)->tv_sec CMP (b)->tv_sec))
#define timeradd(a, b, result)                  \
  do {                        \
    (result)->tv_sec = (a)->tv_sec + (b)->tv_sec;           \
    (result)->tv_usec = (a)->tv_usec + (b)->tv_usec;            \
    if ((result)->tv_usec >= 1000000)               \
      {                       \
  ++(result)->tv_sec;                 \
  (result)->tv_usec -= 1000000;               \
      }                       \
  } while (0)
#define timersub(a, b, result)                  \
  do {                        \
    (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;           \
    (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;            \
    if ((result)->tv_usec < 0) {                \
      --(result)->tv_sec;                 \
      (result)->tv_usec += 1000000;               \
    }                       \
  } while (0)


Australia Forum Administrator #25
Quote:

Well, I grabbed the latest Cygnus (setup.exe and installed it). Everything compiled ok (smaug1.4a). After a make clean/make smaug everything came out fine. Thanks to all for the feedback! Now, is it possible to create a smaug.exe that doesn't require the cygwin1.dll? Just curious. Thanks again.


Ah yes, well that is the better way of doing it. :)

To work without the cygwin1.dll you need to use a different compiler. The version I did with Microsoft Visual C++ didn't need the DLL, however that is not a free compiler.

#26
Hi,

Right. I've got VC 4.5 and that won't read the project files (I think you mentioned you had VC6). No matter, long as I can get it to compile.
Australia Forum Administrator #27
Basically you create a new project and add the .c files into it. These are:



act_comm.c
act_info.c
act_move.c
act_obj.c
act_wiz.c
ban.c
boards.c
build.c
clans.c
comm.c
comments.c
const.c
db.c
deity.c
fight.c
grub.c
handler.c
hashstr.c
ibuild.c
ice.c
icec-mercbase.c
icec.c
ident.c
imc-config.c
imc-events.c
imc-interp.c
imc-mail.c
imc-mercbase.c
imc-util.c
imc-version.c
imc.c
imm_host.c
interp.c
magic.c
makeobjs.c
mapout.c
misc.c
mpxset.c
mud_comm.c
mud_prog.c
planes.c
player.c
polymorph.c
requests.c
reset.c
save.c
services.c
shops.c
skills.c
special.c
stat_obj.c
tables.c
track.c
update.c


#28
Hi, could you teach me how to compile in VC++6? I have the compiler but i don't know how to compile.
Australia Forum Administrator #29
Create a project, add the appropriate files to it, and then "build" it.
#30
Could you show me the exact procedure? And i also want to build a SWR, where can i get the source and how do i compile it?
#31
Okay, i tried compiling swr, and a file is missing, "sys/dir.h". Is it part of the cygwin package or something? I have no idea how to fix it.
Australia Forum Administrator #32

Did you read How to make changes, including compiling?

#33
Thanks.
All that info really did help.