MudOS 是整个Mud的基础。一个成功Mud 不只需要一个成熟的MudLIB,而且需要一个稳定的MudOS。而对于不同版本的MudOS,MudLIB也需要一定的修改。如何修改就不是本文的主要介绍内容,以后有时间继续和大家谈谈如何对于不同版本的MudOS来修改MudLIB。本次的主要内容是如何在 Linux上成功的编译MudOS和使用编译好的MudOS成功架设一个Mud。
现在流行的MudOS有两个版本:MudOS v22pre11和 MudOS v22.1b22。这两个版本的MudOS差异甚大,但是在不同版本的Linux下编译过程基本上是一样的。下面就以v22pre11来介绍如何编译MudOS。
1、获得MudOS 源代码:
对于C ++功力不够的巫师还无法修改。而从这里下载的源代码已经修改好了,不需要修改就可以直接编译。
这里经常见到的错误有
●没有下载原始MudOS源代码的补丁(MudOS V22pre11源代码)。
●原始的MudOS 源代码中的几个文件有错误必须经过修改后才能成功架设Mud。否则就虽然能成功编译MudOS 但是启动Mud 时会出现各种的错误。
2、上传源代码到服务器。
在上传过程中有些朋友会做出一些致命的错误如下:
●将下载回的tar 压缩包解开后在用WinZip压缩后才上传。×这个是不行的。因为用WinZip压缩后的所有文件都为Dos格式。Linux或Unix下的文件格式不同。所以在服务器解压开的文件内每行尾都有一个^M的符号。Unix是不能承认的。无法编译成功。
自然做法只有一个了,把从这里下载的MudOS V22pre11源代码直接上传到服务器,用Linux特有的解压命令进行解压:
命令格式:
解压 tar -zcvf XX.tgz XX 或者zcat XX.tar|tar xv
3、执行编译初始化Shell命令集。
执行命令:
./build.MudOS
常见问题:
●没有严格遵守Lunix和Unix下的文件名格式。(只要做好上面一步上传工作就没问题)
●要严格打入build.MudOS。
●还有一点就是字母的大小写问题也使很重要的,大写的就必须大写,小写的就必须小写,否则错误。
推荐:
由于不同的Lunix版本,使用的Shell也不同,所以最好用以下格式打入此命令:
./build.MudOS
执行后显示如下:
./build.MudOS
Preparing to build standard MudOS driver ...
Trying out some stuff to see what works; ignore errors ...
./build.MudOS: gmake: command not found
make: Nothing to be done for `nothing'.
./build.MudOS: xlc: command not found
mkdir: cannot make directory `tmp': File exists
install: illegal option -- f
Try `install --help' for more information.
rm: tmp/insttest: No such file or directory
mkdir: cannot make directory `obj': File exists
***************** Configuration completed **************
Installing MudOS on Linux
Using install -c to install binaries in ../bin.
Using gcc -E for preprocessing.
Using gcc -O2 -fomit-frame-pointer -fstrength-reduce to compile.
Using bison -d -y to make the compiler.
Edit GNUmakefile if this is not what you want
Otherwise, type 'make' to build MudOS, then 'make install'.
图片:
4、执行编译清除旧文件。
命令格式: make clean
执行后显示情况如下:
make clean
(cd packages; make clean)
make[1]: Entering directory `/home/zeus/mudos/v22pre11/v22pre11/src/packages'
rm -f *.o
rm -f packages.a
make[1]: Leaving directory `/home/zeus/mudos/v22pre11/v22pre11/src/packages'
(cd mudlib; make clean)
make[1]: Entering directory `/home/zeus/mudos/v22pre11/v22pre11/src/mudlib'
rm -f *.o
rm -f mudlib.a
make[1]: Leaving directory `/home/zeus/mudos/v22pre11/v22pre11/src/mudlib'
rm -rf obj *.o *.tab.c *.tab.h
mkdir obj
rm -f efun_defs.c option_defs.c
rm -f opcodes.h efunctions.h opc.h efun_protos.h
rm -f malloc.c mallocwrapper.c
rm -f func_spec.cpp files
rm -f grammar.y comptest* a.out
rm -f packages/Makefile packages/GNUmakefile packages/packages
rm -f Makefile.MudOS GNUmakefile.MudOS
rm -f cc.h edit_source
rm -f core y.output testsuite/core testsuite/tmp/*
rm -rf testsuite/binaries
rm -f testsuite/OBJ_DUMP* testsuite/test_file testsuite/testfile
rm -f testsuite/tmp_eval_file.c testsuite/sf.o testsuite/ed_test
rm -f testsuite/log/log testsuite/log/debug.log testsuite/log/compile
find . -name "*~" -print | xargs rm
rm: too few arguments
Try `rm --help' for more information.
make: [clean] Error 123 (ignored)
find . -name "*.orig" -print | xargs rm
rm: too few arguments
Try `rm --help' for more information.
make: [clean] Error 123 (ignored)
find . -name "*.rej" -print | xargs rm
rm: too few arguments
Try `rm --help' for more information.
make: [clean] Error 123 (ignored)
rm -f *.ln tags TAGS
rm -f driver driver.old addr_server
rm -f Dependencies tmpdepend
touch Dependencies
图象显示:
5、执行编译命令集。
命令格式: ./make (这个和原程序中的makefile对应的)
执行后显示情况:
make
rm -f cc.h
echo "/* this file automatically generated by the Makefile */" > cc.h
echo '#define COMPILER "gcc"' >> cc.h
echo '#define OPTIMIZE "-O2 -fomit-frame-pointer -fstrength-reduce"' >> cc.h
echo '#define CFLAGS " -O2 -fomit-frame-pointer -fstrength-reduce"' >> cc.h
echo '#define OBJDIR "obj"' >> cc.h
gcc -o obj/edit_source.o -c edit_source.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/hash.o -c hash.c
bison -d -y make_func.y
rm -f make_func.tab.c
mv y.tab.c make_func.tab.c
gcc -o obj/make_func.tab.o -c make_func.tab.c
gcc obj/edit_source.o obj/hash.o obj/make_func.tab.o -o edit_source
if test \( ! -r configure.h \) -o \( ! -r configuration \); then \
rm -f configuration; \
touch configuration; \
fi
if test "Machine `uname -a` Configure version 5" = "`cat configuration`"; then \
echo "Skipping configuration ..."; \
else \
./edit_source -configure; \
echo "Machine `uname -a` Configure version 5" > configuration; \
fi
Skipping configuration ...
./edit_source -options -malloc -build_func_spec 'gcc -E ' \
-process grammar.y.pre
No "local_options" file present. If you create one from "options.h",
you can use it when you get a new driver, and you will be warned if there are
changes to the real options.h which you should include in your local file.
Writing build options to option_defs.c ...
unlink malloc.c: No such file or directory
unlink mallocwrapper.c: No such file or directory
Using memory allocation package: sysmalloc.c
link mallocwrapper.c: No such file or directory
Building compiler files ...
Creating 'grammar.y' from 'grammar.y.pre' ...
./edit_source -process packages/Makefile.pre
Creating 'packages/Makefile' from 'packages/Makefile.pre' ...
./edit_source -process packages/GNUmakefile.pre
Creating 'packages/GNUmakefile' from 'packages/GNUmakefile.pre' ...
./edit_source -process mudlib/Makefile.pre
Creating 'mudlib/Makefile' from 'mudlib/Makefile.pre' ...
./edit_source -process mudlib/GNUmakefile.pre
Creating 'mudlib/GNUmakefile' from 'mudlib/GNUmakefile.pre' ...
./edit_source -build_efuns
Building efun tables ...
touch mallocwrapper.c
touch malloc.c
touch files
make -C packages 'CC=gcc' 'CFLAGS= -O2 -fomit-frame-pointer -fstrength-reduce' 'OBJDIR=../obj' 'RANLIB=ranlib'
make[1]: Entering directory `/home/zeus/mudos/v22pre11/v22pre11/src/packages'
gcc -I../obj -I.. -O2 -fomit-frame-pointer -fstrength-reduce -o ../obj/uids.o -c uids.c
gcc -I../obj -I.. -O2 -fomit-frame-pointer -fstrength-reduce -o ../obj/contrib.o -c contrib.c
gcc -I../obj -I.. -O2 -fomit-frame-pointer -fstrength-reduce -o ../obj/sockets.o -c sockets.c
gcc -I../obj -I.. -O2 -fomit-frame-pointer -fstrength-reduce -o ../obj/develop.o -c develop.c
gcc -I../obj -I.. -O2 -fomit-frame-pointer -fstrength-reduce -o ../obj/math.o -c math.c
gcc -I../obj -I.. -O2 -fomit-frame-pointer -fstrength-reduce -o ../obj/parser.o -c parser.c
gcc -I../obj -I.. -O2 -fomit-frame-pointer -fstrength-reduce -o ../obj/mudlib_stats.o -c mudlib_stats.c
ar rcu packages.a ../obj/uids.o ../obj/contrib.o ../obj/sockets.o ../obj/develop.o ../obj/math.o ../obj/parser.o ../obj/mudlib_stats.o
ranlib packages.a
make[1]: Leaving directory `/home/zeus/mudos/v22pre11/v22pre11/src/packages'
make -C mudlib 'CC=gcc' 'CFLAGS= -O2 -fomit-frame-pointer -fstrength-reduce' 'OBJDIR=../obj' 'RANLIB=ranlib'
make[1]: Entering directory `/home/zeus/mudos/v22pre11/v22pre11/src/mudlib'
gcc -I../obj -I.. -O2 -fomit-frame-pointer -fstrength-reduce -o ../obj/interface.o -c interface.c
ar rcu mudlib.a ../obj/interface.o
ranlib mudlib.a
make[1]: Leaving directory `/home/zeus/mudos/v22pre11/v22pre11/src/mudlib'
bison -d -y grammar.y
rm -f grammar.tab.*
sed "s/y.tab.c/grammar.tab.c/g" y.tab.c > grammar.tab.c
mv y.tab.h grammar.tab.h
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/grammar.tab.o -c grammar.tab.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/lex.o -c lex.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/main.o -c main.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/rc.o -c rc.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/interpret.o -c interpret.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/simulate.o -c simulate.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/file.o -c file.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/object.o -c object.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/backend.o -c backend.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/array.o -c array.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/mapping.o -c mapping.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/comm.o -c comm.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/ed.o -c ed.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/regexp.o -c regexp.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/swap.o -c swap.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/buffer.o -c buffer.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/crc32.o -c crc32.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/malloc.o -c malloc.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/mallocwrapper.o -c mallocwrapper.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/class.o -c class.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/efuns_main.o -c efuns_main.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/efuns_port.o -c efuns_port.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/call_out.o -c call_out.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/otable.o -c otable.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/dumpstat.o -c dumpstat.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/stralloc.o -c stralloc.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/port.o -c port.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/reclaim.o -c reclaim.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/parse.o -c parse.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/simul_efun.o -c simul_efun.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/sprintf.o -c sprintf.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/program.o -c program.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/compiler.o -c compiler.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/avltree.o -c avltree.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/icode.o -c icode.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/trees.o -c trees.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/generate.o -c generate.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/scratchpad.o -c scratchpad.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/socket_efuns.o -c socket_efuns.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/socket_ctrl.o -c socket_ctrl.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/qsort.o -c qsort.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/eoperators.o -c eoperators.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/socket_err.o -c socket_err.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/md.o -c md.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/strstr.o -c strstr.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/disassembler.o -c disassembler.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/binaries.o -c binaries.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/ualarm.o -c ualarm.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/replace_program.o -c replace_program.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/ccode.o -c ccode.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/cfuns.o -c cfuns.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/compile_file.o -c compile_file.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/crypt.o -c crypt.c
mv -f driver driver.old
mv: driver: No such file or directory
make: [driver] Error 1 (ignored)
gcc -O2 -fomit-frame-pointer -fstrength-reduce obj/grammar.tab.o obj/lex.o obj/main.o obj/rc.o obj/interpret.o obj/simulate.o obj/file.o obj/object.o obj/backend.o obj/array.o obj/mapping.o obj/comm.o obj/ed.o obj/regexp.o obj/swap.o obj/buffer.o obj/crc32.o obj/malloc.o obj/mallocwrapper.o obj/class.o obj/efuns_main.o obj/efuns_port.o obj/call_out.o obj/otable.o obj/dumpstat.o obj/stralloc.o obj/hash.o obj/port.o obj/reclaim.o obj/parse.o obj/simul_efun.o obj/sprintf.o obj/program.o obj/compiler.o obj/avltree.o obj/icode.o obj/trees.o obj/generate.o obj/scratchpad.o obj/socket_efuns.o obj/socket_ctrl.o obj/qsort.o obj/eoperators.o obj/socket_err.o obj/md.o obj/strstr.o obj/disassembler.o obj/binaries.o obj/ualarm.o obj/replace_program.o obj/ccode.o obj/cfuns.o obj/compile_file.o obj/crypt.o -o driver packages/packages.a mudlib/mudlib.a `cat system_libs`
gcc -O2 -fomit-frame-pointer -fstrength-reduce -o obj/addr_server.o -c addr_server.c
gcc -O2 -fomit-frame-pointer -fstrength-reduce obj/socket_ctrl.o obj/addr_server.o obj/port.o \
-o addr_server `cat system_libs`
6、安装编译出的MudOS。
命令格式:./make install
显示情况如下:
if test \( ! -r configure.h \) -o \( ! -r configuration \); then \
rm -f configuration; \
touch configuration; \
fi
if test "Machine `uname -a` Configure version 5" = "`cat configuration`"; then \
echo "Skipping configuration ..."; \
else \
./edit_source -configure; \
echo "Machine `uname -a` Configure version 5" > configuration; \
fi
Skipping configuration ...
mkdir ../bin
mkdir: cannot make directory `../bin': File exists
make: [install] Error 1 (ignored)
install -c driver ../bin
install -c addr_server ../bin
图象显示:
7、架设MudLIB
这个就非常简单了命令格式:./driver config.XXX(根据不同的人设置)
你在用linux的时候会发现如果少用一个符号来驱动程序就会退不出当前环境,呵呵,这个符号"&"也。
对了还有个工具也是必不可少的介绍如下:
就是用于转化DOS格式到Linux或者Unix格式的超级工具convert
本工具可以进行GB <-> BIG5以及进行文本文件的dos <-> unix格式的转换
有很多朋友把游戏从Win下向Unix移植时会遇到配置文件错误的问题,其实这就是因为Win系统下的文本文件格式与Unix下的标准不一致造成的。这个工具在Unix或Linux下输入gunzip convert-1_0.tgz解压缩,然后tar -xvf conver*.tar释放文件出来, cd convert-1.0后运行make命令编译!可能需要gcc的支持!编译成功后即生成gb2big,big2gb,dos2unix, unix2dos,hc等五个可执行文件,加参数--help即可以得到使用帮助
现在你应该发现编译MudOS不是很难吧!