Win32 PennMUSH and MySQL
While we cannot distribute precompiled Windows binaries of PennMUSH with MySQL support compiled in and enabled, I have written a README for building your own binary of PennMUSH using the Windows installation of MySQL available from the MySQL website. The README.MySQL is currently available as a part of the 1.7.7p34 tarball, in the win32 directory.
My instructions were primarily drawn from using MSVC++ to compile the binaries, but they should work with little to no changes in a MSys + MinGW environment and a more standard unix-like build process (./Configure -d ; make ; make install ).
With that said, the MySQL support is still relatively new, and as such hasn't received extensive testing upon Windows by me. I will attempt to provide what support I can for issues that arise.

Click 

Documentation?
Hi,
Do you have a link to documentation about the MySQL features, please? Does the MySQL build completely replace the flat database files?
Thanks in advance,
EricT.
MySQL support
SQL support (Penn now has MySQL, PostgreSQL and SQLite) doesn't affect the way Penn saves it's own data - the normal game (and mail and chat) databases are saved the same as ever. It just enables the @sql command (and sql() function) so you can write code that accesses data stored in an SQL database. It's mainly used to provide a simpler way to store and query data than keeping things on objects in attributes, and also to make certain bits of data available both in and out of the MUSH (character bios, player's mail or bb posts, news files, etc).
Building for Windows using MinGW
Well, I bit the bullet and had a go at building with Bloodshed Dev C++ (importing the MSVC6 .dsp) and nearly got there with a spate of warnings. I got stuck, however, when I found that I didn't have crtdefs.h (and any h's that includes) which presumably comes with full MS products.
So ... I'm now trying to build Pennmush 1.8.3p6 for Windows with MySQL and OpenSSL using MinGW and have come across a few problems I could do with some help with. I've tried to follow the instructions in /Win32/readme.mingw.
With ./Configure --with-ssl=/openssl [ --includedir=c:/mingw/include --libdir=c:/mingw/lib ]
MySQL is found OK.
OpenSSL is found OK.
Perl is not found. Perl.exe is in c:/perl/bin and I have the following entries in MSys's /etc/fstab:
#Win32_Path Mount_Point
c:/mingw /mingw
c:/perl/bin /perl
(nor does c:/perl ..... /perl find perl.exe)
c:/pennmuss /pennmuss
c:/openssl /openssl
(I notice that in the listing the file suffixes found are said to be ".exe" with a leading dot and "o" without. Not sure if that's relevant).
After that many of the items checked produce the response "no" (though the minGW installation did provide the .a libaries). These especially include winsock-related stuff which I appear to be missing from my machine:
netdb.h; /arpa/ files; /netinet/ files; /sys/socket.h
Others checked and response = "no":
test indent ctags etags exctags uptime sendmail floatingpoint.h libintl.h sys/errno.h sys/in.h sys/mman.h sys/page.h sys/un.h ieeefp.h sys/resource.h sys/event.h sys/uio.h poll.h sys/epoll.h sys/select.h; socklen_t; gettext in -lintl; crypt in -lcrypt; pcre; bindtextdomain; crypt; fpsetmask; fpsetround; isnormal; gai_strerror; getaddrinfo; getdate; gethostbyname2; getnameinfo; getpagesize; getrlimit; getrusage; gettext; getpid; getppid; inet_pton; setitimer; setlocale; fork; vfork; setsid; settpgid; settpgrp; cbrt; log2; getuid; geteuid; seteuid; getpriority; setpriority; socketpair; sigaction; sigprocmask; imaxdiv; valloc; writev; fcntl; pselect; poll; ppoll; pollts; kqueue; epoll_ctl; snprintf; vsnprintf; _vsnprintf_s; strcasecmp; _stricmp; _strnicmp; strdup; sysconf; textdomain; waitpid; wait3; wait; union wait; h_errno; sockaddr_in6;
Clearly I'm doing something wrong and/or I'm missing something from the new MinGW/MSys install or need to install addional items not mentioned in the instructions. Any ideas, please?
From installed.ini:
runtime=mingw-runtime-3.14.tar.gz
w32api=w32api-3.11.tar.gz
binutils=binutils-2.17.50-20060824-1.tar.gz
core=gcc-core-3.4.5-20060117-3.tar.gz
gpp=gcc-g++-3.4.5-20060117-3.tar.gz
g77=
ada=
java=
objc=gcc-objc-3.4.5-20060117-3.tar.gz
make=mingw32-make-3.81-20080326-2.tar.gz
Sorry this post is so long. Many thanks in advance, Eric T.
Stuff you may be missing
I'm not an expert in mingw32 compiles (I usually go with cygwin), but it sounds like you're missing some development packages for gcc with all the headers and stuff. Check for those? You also probably want to install libpcre and gettext if you don't have those alreayd.
Also, the README.mingw example shows the win32 path for perl as c:/perl, not c:/perl/bin, but I don't know if that matters.
Building for Windows using Dev C++
When I attempted to build using Bloodshed Dev0-C++, btw, I found that DevC/include/sys/types.h declares ssize as long (line 101) and pennmuss/config.h declares it as int (line 292).
I wasn't sure whether to go with the int or the long (removing the surplus entry).
But, as I said, I got stuck minus crtdefs.h and any h's that includes. Looked like Dev-C++ had all the libraries I'd have needed.
Cheers,
Eric T.
Building for Windows using MinGW
Thanks for your help, Javelin.
"Checking for Perl" -- no
I copied perl.exe to c:/perl from /perl/bin/ and changed /etc/fstab to suit, still not detected.
"Checking lib pcre" -- EDIT yes
I downloaded pcre-7.0-bin.zip and pcre-7.0-lib.zip and placed the directories (bin, lib, include etc) in the /MingGW/ folder.
"Checking for gettext" -- yes
and libintl.h -- yes
EDIT: I downloaded
gettext-0.16.1-1-bin.tar.bz2
gettext-0.16.1-1-dll.tar.bz2
from the MSys section of MinGW downloads.
This in turn requires:
GNU libiconv (1.9.1 or newer), so
I downloaded libiconv-1.9.2-1-bin.zip to /MinGW/ folders.
Still working on what gcc development packages I may be lacking and where to get them.
Thanks again,
Eric T.
Building for Windows with MinGW: sockets
Configure looks at -lsocket, so I presume the library I'm missing is libsocket? Is there a port of libsocket for MinGW? I tried a djgpp version I have to no avail (lots of errors) and google came up with a few old, broken links.
EDIT: Maybe worth zipping up a working set of files -- if it's a rare item -- and making available for download? Just a thought.
It also looks for:
-lnsl, so again I guess I'm missing libnsl.
-lz, have now got zlib dll,libs and includes.
btw, the instructions make no mention of copying headers from /Win32/. I take it this is right?
With good wishes,
Eric T.
I think you only need to use
I think you only need to use headers from /Win32/ when you're compiling with MSVC or something similar. If you're using MingW/Cygwin I don't think you need to. (I stopped using MingW b/c I had a lot of trouble getting Penn to compile on it, btw, but I found it a lot easier using cygwin, so that might be worth considering if you keep having problems. 1.8.3p6 has some issues with Cygwin, though, so try p5 instead if you go that route.)
I think you only need to use
Thanks for the info, Talvo.
Once I've cleared out the clutter of previous multiple attempts to find a way of building pennmush (for free), I'll have a go with cygwin and 1.8.3p5.
With good wishes,
Eric T.
Building for Windows with Cygwin
OK, have bitten the bullet as suggested. With thanks, cygwin downloaded and installed perfectly.
CONFIGURE (1.8.3p5)
--------------
Ran configure for a MySQL and OpenSSL setup which went like a dream:
./configure --with-mysql=/home/erict/pennmush/mysql_configmysql_config is a script that comes with MySQL source.
MySQL and OpenSSL were found OK.
MAKE INSTALL (1.8.3p5)
-----------------
Had some errors which I don't fully understand.
(1) Msgfmt not found. Already had gettext, downloaded gettext-devel using cygwin setup.exe. Sorted.
(2) msgfmt --strict .po
msgfmt error while opening ".po" for reading: No such file or directory.
reason: $(LANG) language localization not set. Have ignored this.
{mkdir -p /LC_MESSAGES created okay}
(3) mv messages.mo /LC_MESSAGES/pennmush.mo
mv: cannot stat 'messages.mo': No such file or directory.
(4) attrib.c:605: error: conflicting types for 'atr_add'
{atr_add(dbref thing, const char *RESTRICT atr, const char *RESTRICT s, dbref player, unsigned int flags)}
hdrs/attrib.h:58:error: previous declaration of 'atr_add was here.
{extern atr_err atr_add(dbref thing, char const *RESTRICT atr, char const *RESTRICT s, dbref player, uint32_t flags);}
QUESTION: Should I change one of unsigned int or uint32_t ? Or is the problem further back in the declaration of these types?
EDIT: Sorted: http://dev.pennmush.org/ticket/7471
attrib.c changed to uint32_t in 1.8.3p6.
Make then exited.
Thanks again,
Eric T.
Building for Windows with Cygwin
MAKE INSTALL
-----------------
(1) Cannot find -lmysqlclient.
Checked makefile: SQL_CFLAGS=-I/usr/local/include/mysql
SQL_LDFLAGS=-L/usr/local/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm
So moved includes and headers to these [-I and -L] directories from /mysql/include and mysql/lib/opt respectively. Sorted.
(2) Cannot find -lnsl. I presume this is "Name services library, a library of name service calls (getpwnam, getservbyname, etc...) on SVR4 Unixes. GNU libc uses this for the NIS (YP) and NIS+ functions." Should we be linking to this anyway (Vista machine)?
With good wishes, Eric T.
Building for Windows with Cygwin: Linking
LINKING
----------
I received many errors such as:
sql.o: In function 'sql_error': /gome/erict/pennmush/src/sql.c: 184: undefined reference to '_my_sql_error'.
Looking in makefile, the line:
SQL_LDFLAGS=-L/usr/local/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm
wasn't finding libmysql, so I added -lmysql and the build went ok:
SQL_LDFLAGS=-L/usr/local/lib/mysql -lmysqlclient -lmysql -lz -lcrypt -lm
I also took out -lnsl from the line above which went without any warnings.
The good news is, the exe built, but have yet to check if the exe actually works.
With good wishes and thanks,
Eric T.
Building for Windows with Cygwin: Running
RUNNING
-----------
I'm not sure how to run the exe. Whether from a windows command prompt or from within Cygwin. I tried the new cygwin exe with my existing mush.
It didn't like netmud.exe /run and the bat window disappeared before I could read what it said, so I opened up a windows elevated command prompt, cd'ed to / game / and ran without the / run switch. This was the output:
[06/08 18:49:47] 1.8.3
[06/08 18:49:47] MUSH restarted, PID 5832, at Sun Jun 08 18:49:47 2008
[06/08 18:49:47] Couldn't read all of 'txt/connect.txt'
. . .
[06/08 18:49:47] Couldn't read all of 'html/connect.html'
. . .
[06/08 18:49:47] Couldn't open data/indb! Creating minimal world.
[06/08 18:49:47] Reading access.cnf
[06/08 18:49:47] Reading mush.cnf
[06/08 18:49:47] Reading alias.cnf
[06/08 18:49:47] Reading restrict.cnf
. . .
[06/08 18:49:47] CONFIG: option MASTER_ROOM not a valid room! (as now a minimal db)
[06/08 18:49:47] Seeding OpenSSL random number pool.
[06/08 18:49:47] Seeded after 1 cycle.
Listening on port 8081 using IPv4.
[06/08 18:49:47] 252 file descriptors available.
[06/08 18:49:47] RESTART FINISHED.
setitimer: Invalid argument
. . .
With good wishes,
eric.
You want to run the exec
You want to run the exec from within cygwin, rather than a Windows cmd prompt. (I've never actually run it on Vista, btw, only on XP, so I'm working on the assumption it'll all work the same.)
Make sure that when you edit all the *.txt / *.cnf etc files you use a text editor that saves them with Unix lineendings, by the way. I wouldn't have thought that would be the reason for the "Couldn't read all of 'txt/connect.txt'" message (since a Win line ending is \r\n and a unix is \n), though, so not sure why you're getting that. Possibly the files were saved incorrectly without a trailing newline or something?
The setitimer: Invalid argument you can ignore - it's not available on cygwin, but Penn works fine anyway.
Other than that, though, it looks good. Did you manage to connect on 'localhost:8081' after doing that?
You want to run the exec
Hi Talvo,
Thanks for your input.
LF or CRLF
-------------
Ah ... When I installed Cygwin it asked me if I wanted files writing with LF or CRLF. I checked the latter.
My existing (fully working) MUSH has been run on the official Win32 1.8.3p6 exe and if open the databases up in Notepad it looks like they're LF only.
EDIT: Yes, hex editor shows LF line endings and LF at the end of the file. I presume a 1.8.3p6 database will open with p5 exe?
Hlp, txt, html and cnf files I edited in Wordpad and these have CRLF endings. The text and html files all have a CRLF at the end of the file. Logs have been written with CRLF.
EDIT: Dash and bother, I could have used Hurricane Editor which generates LF only.
Looking at connect.txt with my hex editor, I do indeed see that the file ends in 0D0A (CRLF).
Connect
----------
"Did you manage to connect on 'localhost:8081' after doing that?"
Yes, I was told that the world was Pueblo-enhanced and that the character I wanted to connect to didn't exist (as a minimal db had been set up). I could connect as One in room 0, QUIT and @shutdown.
Several times yesterday I was told that the address was in use and I can see from the port monitor I wrote that the 8081 connection/s though no longer established was still in one of the waiting states on the way to closing.
With good wishes,
Eric.
Couldn't read all of txt/xyz.txt
Hi,
Sorted this by getting dos2unix.exe from Nick Gammon's site and running it on the txt and html files to get back to LF line endings.
Cheers,
Eric T.
Couldn't open data/indb!
SORTED: Re: Couldn't open data/indb! Creating minimal world.
I noticed that the cygwin version of pennmush I'm compiling reports "compress_program gzip" which my working mush doesn't use.
@shutdown of the minimal db saved the data in .gz archives. So I gzipped my working database and -- lo! and behold! -- I can start up my working database with compression.
That is with the following in mush.cnf (an oversight on my part):
#not used on Win32 (sic)
compress_program gzip
uncompress_program gunzip
compress_suffix .gz
I can also start my working database without compression.
#not used on Win32
compress_program
uncompress_program
compress_suffix
Cheers,
Eric T.
Glad to hear you got it all
Glad to hear you got it all working :) I'll have to pick your brains one of these days about getting it working with MySQL under cygwin, that's something I've never actually managed to do successfully.
Regards,
Mike
Alas for MySQL ...
Hi Mike, not all working yet:
DNS
---
Looks like it's working. Last site shows the domain name and can connect as god to the local machine, obeying the ip address and domain name check in access.cnf.
OpenSSL
-------
This is working fine now, though the cygwin build seems more prone to "network address already in use" errors -- have to wait until the port is fully closed.
MySQL
-----
This could be broken. See http://dev.pennmush.org/ticket/7586 .
MySQL shows in @config compile; there were no errors in compile.
There are no sql entries in the logs, which makes it difficult to see what's going on.
First time round:
think sql(SELECT 1) returned "No SQL database connection" though I have a working database and user set up in mySQL and mush.cnf.
After that:
this and @sql requests closed down the MUSH without warning.
Also noticed that sometimes (maybe related to these crashes) the database move from /data/ to /save/ goes wrong and outdb disappears.
Getting there slowly.
Cheers,
Eric T.
Building MySQL with Cygwin
I successfully followed the simple instructions at:
http://cygwin.com/ml/cygwin/2006-01/msg00772.html to build MySQL from source with Cygwin.
This suggests getting the MySQL linux tar.gz source and using configure, make and make install on that (go make yourself lunch and check back on progress at intervals, or bed down for the night). I'm using MySQL Community 4.1.22, btw, so that if necessary I can run it on an old Win98 machine.
Configure told me that the compiler can't convert between a long long and a float ... upgrade to egcs 1.0.3 or newer.
In the hope that I could simply avoid the use of long long to float conversion, in configure I hardwired inac_cv_conv_longlong_to_float=yes before being told: "Your compiler cannot convert a longlong value to a float! If you are using gcc 2.8.# you should upgrade to egcs 1.0.3 or newer and try again".
The build succeeded. libmysqlclient.a and co. according to *my* pennmush makefile need to be in /usr/local/lib/mysql/. mysql.h and co. need to be in /usr/local/include/mysql . In case that didn't find them, I copied libmysqlclient.a to my mysql windows binary directory /mysql/lib/opt and made sure mysql.h was in /mysql/include/. Sorry, in the flurry of activity I'm not sure if that was necessary.
Instructions at the mysql site are far more tortuous, use BitKeeper and require care, it says, to produce a stable library not prone to random crashes.
The German site offering cygwin ports of things like the client is not available (fwiw, see http://lists.mysql.com/win32/28 ).
The Pennmush makefile should link to -lmysqlclient, not -lmysql as I previously foolishly stated. That it worked but crashed is probably a fluke. I don't have libnsl, so I took out -lnsl, not sure if that's right. -lcrypt is needed assuming you have and are using libcrypt.
From *my* makefile:
SQL_CFLAGS=-I/usr/local/include/mysql
SQL_LDFLAGS=-L/usr/local/lib/mysql -lmysqlclient -lz -lcrypt -lm
RESULT
------
@sql twit
SQL: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'twit' at line 1
a wandering dervish has arrived.
@sql update test set name='name1' where id=1
SQL: 1 rows affected.
@sql select * from test
Row 1, Field id: 1
Row 1, Field name: name1
Row 2, Field id: 2
Row 2, Field name: name2
Yahoo! Success. Well, barring a "soak test" to check on stability.
Eric T.