Compiling Smaug

Posted by Yakir on Wed 15 Aug 2001 02:50 PM — 18 posts, 74,391 views.

#0
Does anyone know what is the syntax for using the free Borland C++ Builder 5.5 command line version (which you can download at http://members.nbci.com/_XMCM/comscigate/environ/compiler/borland/bc55.exe) to compile Smaug with the makefile that comes with Smaug1.4a.sce.tgz that I downloaded from this site?
The only other way I know is to make a batch file, but I'd rather not do the work =P
So, if anyone knows how do this, please post the answer. I'd realy apreciate.
Australia Forum Administrator #1

Has that compiler been publicly released? I couldn't see it on the Borland site. I suggest using Cygwin, I have done a lengthy description about compiling with that, step by step. Read about it at How to make changes, including compiling

Amended on Thu 16 Aug 2001 02:05 AM by Nick Gammon
#2
Hey, thanks for the response. I'll try Cygwin and read the documentation.
My brother, a professional programmer and sys admin for a learning tools site forwarded me some email he got about the Borland C++ Builder 5.5 being released for free download and use as of about a month ago. You goto www.borland.com and click on downloads on the top left of the page. On the downloads page there should be a two column list of 'Product Downloads'. Click on 'C++Builder Compiler 5.5'. From there it should be pretty self explanitory. Though keep in mind, it's only the core compiler and afeew simple utils. It doesn't come with all the visual tools (GUI). It's all command line so it won't work I think on Windows ME unless you've installed Real Dos mode yourself (i think).
#3
I just went to download Setup.exe for Cygwin from download.com because www.cygwin.com doesn't seem to be there for some reason. I downloaded the setup.exe file, but it tried to connect to download the other files but couldn't connect. So I can't get my hands on Cygwin. Does anyone know where the whole thing is online that I might download it?
#4
Ok, nevermind. I went to http://sources.redhat.com/cygwin/ and that seemed to work. I'm actualy downloading Cygwin now. Well, thanx a lot for your help. Your section on compiling and editing the codebase using cygwin has been -extremely- helpful.
Australia Forum Administrator #5
Out of curiosity, I downloaded the Borland C 5.5 compiler from the site you mentioned (www.borland.com), and tried to compile SMAUG, just to see what would happen.

After a considerable amount of mucking around I got it to compile. First, you can simplify your job if you replace the makefile with the lines below. Note that the two lines in bold start with leading tab, not spaces, or it won't work.

In the example the compiler is on the C drive, you would change the "c:" on the first line (in two places) if it is somewhere else.


CPP      = bcc32 -Ic:\borland\bcc55\include -Lc:\borland\bcc55\lib -DSMAUG
CPPFLAGS = -w-8057 -w-8066 -w-8004 -w-8060 -w-8065 -w-8012 -w-8075 -w-8008

O_FILES = act_comm.obj act_info.obj act_move.obj act_obj.obj act_wiz.obj boards.obj \
          build.obj clans.obj comm.obj comments.obj const.obj db.obj deity.obj fight.obj \
          handler.obj hashstr.obj ibuild.obj ident.obj interp.obj magic.obj makeobjs.obj \
          mapout.obj misc.obj mpxset.obj mud_comm.obj mud_prog.obj player.obj polymorph.obj \
          requests.obj reset.obj save.obj shops.obj skills.obj special.obj tables.obj \
          track.obj update.obj grub.obj stat_obj.obj ban.obj services.obj planes.obj \
          imm_host.obj colorize.obj 

all:
	make smaug

smaug: $(O_FILES)
	$(CPP) -esmaug.exe $(O_FILES)

clean:
   -@if exist *.obj del *.obj                 >nul
   -@if exist *.exe del *.exe                 >nul

.c.obj:
    $(CPP) $(CPPFLAGS) -c {$? }



Then various files needed minor tweaking. I will paste below the patches needed to change from the "smaug with MXP" source on my downloads page, to the version that compiled OK under Borland.

You can use the patch utility (that comes with Cygwin) to apply them, or assuming you don't have Cygwin (or you may as well compile with that) you can apply them by hand. Each patch consists of the file name (eg. the first one is to the file comm.c) then a line number (eg. line 34), and then "from" lines (preceded by a < sign), and then "to" lines (preceded by a > sign).

Thus, the first patch means "add the line '#define WIN32'" at line 34.

The second patch means "change line 56 by adding '(unsigned char)' as indicated, and so on.



diff  orig_src/comm.c src/comm.c
34c34
< 
---
> #define WIN32
56c56
<   #define  IAC                '\xFF'
---
>   #define  IAC                (unsigned char) '\xFF'
125a126,128
> bool DONT_UPPER;
> int     area_version;
> bool	MOBtrigger;
163,165c166,168
< #ifdef WIN32
<   int mainthread( int argc, char **argv )
< #else
---
> //#ifdef WIN32
> //  int mainthread( int argc, char **argv )
> //#else
167c170
< #endif
---
> //#endif
275,276c278,281
< 	signal(SIGINT, (void *) bailout);
< 	signal(SIGTERM, (void *) bailout);
---
> //	signal(SIGINT, (void *) bailout);
> //	signal(SIGTERM, (void *) bailout);
> 	signal(SIGINT,  bailout);
> 	signal(SIGTERM, bailout);
336c341
< 		shutdown_checkpoint ();
---
> //		shutdown_checkpoint ();
diff  orig_src/db.c src/db.c
29a30
>   #define strcasecmp strcmp
diff  orig_src/deity.c src/deity.c
24a25,26
> #undef WIN32
> 
diff  orig_src/ident.c src/ident.c
23a24
> /*
27a29
>   */
diff  orig_src/magic.c src/magic.c
729c729
<     if ( (*exp == '(') && !index(exp+1,'(') && exp[strlen(exp)-1] == ')' )
---
>     if ( (*exp == '(') && !strchr(exp+1,'(') && exp[strlen(exp)-1] == ')' )
diff  orig_src/misc.c src/misc.c
27a28,29
> #undef WIN32
> 
2098,2101d2099
< #ifdef WIN32
< 
< /* routines not in Windows runtime libraries */
< 
2106a2105,2109
> 
> 
> #ifdef WIN32
> 
> /* routines not in Windows runtime libraries */
diff  orig_src/mud.h src/mud.h
34a35
> /*
41a43
> */
42a45,47
> #include <time.h>
> #include <winsock.h>
> 
273c278
< bool DONT_UPPER;
---
> extern bool DONT_UPPER;
293c298
< int     area_version;
---
> extern int     area_version;
1049c1054
< bool	MOBtrigger;
---
> extern bool	MOBtrigger;
5434a5440
> /*
5452a5459,5460
> */
> 
5463,5464c5471,5472
< #define exit(arg) Win32_Exit(arg)
< void Win32_Exit(int exit_code);
---
> //#define exit(arg) Win32_Exit(arg)
> //void Win32_Exit(int exit_code);
diff  orig_src/save.c src/save.c
236c236
< 	fchmod(fileno(fp), S_IRUSR|S_IWUSR | S_IRGRP|S_IWGRP | S_IROTH|S_IWOTH);
---
> //	fchmod(fileno(fp), S_IRUSR|S_IWUSR | S_IRGRP|S_IWGRP | S_IROTH|S_IWOTH);



I added the path to the Borland compiler (eg. "c:\borland\bcc55\bin") into my "PATH" variable so it could find "make" and bcc32, and then just typed "make".

Make sure you create a "gods" directory at the same level as the player directories, or you will get a crash shortly after starting the server.

Amended on Fri 17 Aug 2001 01:51 AM by Nick Gammon
#6
Could you, please, make that downloadable (i.e. Smaug1.4a_MPX.Bor.tgz - Borland version) from your site?
Australia Forum Administrator #7

OK, I have put the source (only) and the makefile, into this file: ftp://ftp.gammon.com.au/smaug/smaug_1.4a_src_mxp_borland.zip (190 Kb).

This download only has the files I had to change to compile under Borland, the other files (area files, source files etc.) are the same as in the download ftp://ftp.gammon.com.au/smaug/smaug1.4a_mxp.tgz. Thus, you should download and unzip that file first (the tgz one) and then unzip the borland file on top of it, so that the contents of the src directory are replaced by the 9 files in it.

Amended on Fri 17 Aug 2001 02:29 AM by Nick Gammon
#8
Thanks alot for the download. You've been a great help.
#9
I replaced the listed src files with for the ones in your download and I'm allready to compile, only I don't know what directory to put my src files into. I tried putting all the src file into the c:\b55\bin\ directory (c:\b55 is my borland builder 5.5 directory) and used the 'make' command, but I got at least 100 different warnings and several compiling errors. So, where should I put the src files and the rest of the directories? Or maybe there is a variable for use with the 'make' command such as 'make c:\smaug\src\' or something of the sort?
Australia Forum Administrator #10
What I did was create a different directory entirely, eg. C:\SMAUG

Then I unzipped the main download into that. Then you would take the "borland" download and put the source files from that into the "src" subdirectory.

Then start up a "command" window, after adding the Borland bin directory to your path. eg. if you type "path" in the command window you should see something like this:

PATH=C:\WINNT\system32;C:\WINNT;C:\borland\bcc55\bin

You can do this in the System Properties -> Environment tab under Windows NT.

Once you have the Borland bin directory in the path, just CD to the src directory and type "make".
#11
Ok, I did exactly what you said to do above, but I got at least 50 or so errors almost all having to do with 'timeval'. The src files that I have are those from the MXP download from this site & the files edited for borland. Here is the message that I get:


:boards.c
'Error E2209 boards.c 18: Unable to open include file 'sys/types.h
'Error E2209 boards.c 19: Unable to open include file 'ctype.h
'Error E2209 boards.c 20: Unable to open include file 'stdio.h
'Error E2209 boards.c 21: Unable to open include file 'string.h
'Error E2209 boards.c 22: Unable to open include file 'time.h
'Error E2209 boards.c 23: Unable to open include file 'sys/stat.h
'Error E2209 mud.h 19: Unable to open include file 'stdarg.h
'Error E2209 mud.h 20: Unable to open include file 'stdio.h
'Error E2209 mud.h 21: Unable to open include file 'stdlib.h
'Error E2209 mud.h 22: Unable to open include file 'limits.h
'Error E2209 mud.h 45: Unable to open include file 'time.h
'Error E2209 mud.h 46: Unable to open include file 'winsock.h
; Error E2139 mud.h 2278: Declaration missing
'Error E2238 mud.h 2279: Multiple declaration for 'time_t
'Error E2344 mud.h 2278: Earlier declaration of 'time_t
; Error E2139 mud.h 2279: Declaration missing
; Error E2139 mud.h 2423: Declaration missing
'Error E2450 mud.h 2848: Undefined structure 'timeval
'Error E2450 mud.h 2849: Undefined structure 'timeval
'Error E2450 mud.h 2850: Undefined structure 'timeval
Error E2141 mud.h 3511: Declaration syntax error
Error E2141 mud.h 3512: Declaration syntax error
Error E2141 mud.h 3515: Declaration syntax error
Error E2141 mud.h 3679: Declaration syntax error
Error E2141 mud.h 3681: Declaration syntax error
Error E2228 mud.h 3681: Too many error or warning messages
*** 26 errors in Compile ***


It just repeats that about 10-15 times each time wit a different file in the place of 'boards.c'. Also I can't copy everything that scrolls on the screen.

Also, another question. How would I go about compiling Smaug using Debian Linux? I know that was a very broad question. Maybe you could just point me to some how-to page or something.
#12
Back to Cygwin... =P
I compiled Smaug using Cygwin and everything was fine till I tried to execute it. This is what happened:


yakir@YAKIR /home/smaug/dist/area
$ src/smaug.exe/..
Tue Aug 28 18:24:35 2001 :: Booting Database
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
-----] Tue Aug 28 18:24:35 2001 :: [*****] BOOT: ---------------------[ Boot Log
---------------
Tue Aug 28 18:24:35 2001 :: Loading commands
...Tue Aug 28 18:24:35 2001 :: Loading sysdata configuration
Tue Aug 28 18:24:35 2001 :: Loading socials
Tue Aug 28 18:24:35 2001 :: Loading skill table
...Tue Aug 28 18:24:35 2001 :: Sorting skill table
Tue Aug 28 18:24:35 2001 :: Remapping slots to sns
Tue Aug 28 18:24:35 2001 :: Loading classes
Tue Aug 28 18:24:35 2001 :: Loading races
Tue Aug 28 18:24:35 2001 :: Loading herb table
Tue Aug 28 18:24:35 2001 :: Loading tongues
Tue Aug 28 18:24:35 2001 :: Making wizlist
0 [main] smaug 1583569 open_stackdumpfile: Dumping stack trace to SMAUG.EX
E.stackdump
)Segmentation fault (core dumped
mped)


What does this mean? What do I do?
Australia Forum Administrator #13
Sounds like you didn't replace the source files in the borland download properly. I got those messages about timeval too.

As for Debian Linux, it should compile by simply un-tar'ing the file, changing to the src directory and typing "make".

The crash is caused by a missing "gods" directory. Put one of that name at the same level as the "player" directory.
#14
Why when I compile, I have more 100 errors:

Warning W8012 imm_host.c 168: Comparing signed and unsigned values in function c
heck_immortal_domain
Warning W8012 imm_host.c 172: Comparing signed and unsigned values in function c
heck_immortal_domain
Warning W8004 imm_host.c 166: 'i' is assigned a value that is never used in func
tion check_immortal_domain
Warning W8060 imm_host.c 316: Possibly incorrect assignment in function do_add_i
mm_host
Warning W8004 imm_host.c 279: 'it' is assigned a value that is never used in fun
ction do_add_imm_host
Warning W8004 imm_host.c 215: 'argument' is assigned a value that is never used
in function do_add_imm_host
Warning W8004 imm_host.c 209: 'arg3' is assigned a value that is never used in f
unction do_add_imm_host
colorize.c:
Warning W8060 colorize.c 40: Possibly incorrect assignment in function load_colo
rs
Warning W8060 colorize.c 72: Possibly incorrect assignment in function save_colo
rs
Warning W8004 colorize.c 181: 'argument' is assigned a value that is never used
in function do_colorize

Help me please :(

I have Windows Me, Borland 5 compiler, I have download smaug1.4a_mxp.tgz and smaug_1.4a_src_mxp_borland.zip etc

:(
USA #15
Can you show us those lines?

Also, why not use SmaugFUSS?
#16
MAKE Version 5.2 Copyright (c) 1987, 2000 Borland
Error makefile 27: Command syntax error
Error makefile 30: Command syntax error
Error makefile 39: Command syntax error
Error makefile 50: Command syntax error
Error makefile 58: Too many rules for target 'smaug'
Error makefile 60: Too many rules for target 'clean'
Error makefile 61: Command syntax error
Error makefile 74: Command syntax error
Error makefile 75: Command syntax error
*** 9 errors during make ***

That is for SmaugFuss
USA #17
I don't think anyone ever successfully compiled it under Borload. Do a search, see what comes up. IE:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=5311&page=999999