Building for Windows with Cygwin

Posted by EricT on Sun 08 Jun 2008 12:31 PM — 10 posts, 40,028 views.

#0
OK, have bitten the bullet as suggested by Nick. With thanks, cygwin downloaded and installed perfectly.

CONFIGURE
========

Ran configure for a MySQL and OpenSSL setup which went like a dream:

./configure --with-mysql=/home/erict/pennmust/mysql_config

mysql_config is a script that comes with MySQL source.

MySQL and OpenSSL were found OK.

MAKE INSTALL
==========

(1) Msgfmt not found. Already had gettext, downloaded gettext-devel using cygwin setup.exe.

(2) msgfmt --strict .po
msgfmt error while opening ".po" for reading: No such file or directory.

[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.


Amended on Sun 08 Jun 2008 03:09 PM by EricT
#1
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 copied 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)?

Couldn't find libnsl via the Cygwin setup.

With good wishes,
EricT.
#2
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.
#3
RUNNING
-----------

I'm not sure how to run the exe. Whether from a windows command prompt or from within Cygwin.

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
...

I could connect as One.

With good wishes,
eric.
#4
Hi, sorted this and can now use my working database.

(a) My edits to txt and html files had added CRLF line endings, so I ran your dos2unix on the files.

(b) Through an oversight, I'd left in the mush.cnf lines that tell the system to use compression.

If I gzipped my working database, pennmush could read it with gzip compression:

#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

Got there in the end.

Next thing to check out is whether domain name resolution works.

Cheers,
Eric T.
#5
Getting there:

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, so 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 crasehs) the database move from /data/ to save goes wrong and outdb disappears.

With thanks and good wishes,
Eric T.
Australia Forum Administrator #6
I haven't played with PennMUSH since they added mySQL so I can't really help with that side of it. Possibly there is a permissions problem, depending on the configuration of mySQL it might be up but refusing connections from the Mush unless it gives the correct password.

You may get more help from the pennmush.org site, as they would be more familiar with the database aspects. Hmmm - I see from the support ticket you mention you are looking around there. That ticket started 2 months ago.

You could always use an earlier version unless you are desperate to have the latest PennMUSH. The other approach is to fire up gdb. At least if you actually get a crash it usually helps point you to the place to look.
#7
Sorry, could be that this is my problem, trying to link to MySQL library libmysqlclient.a not compiled with Cygwin.

Instructions at
http://cygwin.com/ml/cygwin/2006-01/msg00772.html
suggest getting the MySQL linux source and using configure, make and make install on that.

WIP: Configure is telling me that the compiler can't convert between a long long and a float ... upgrade to egcs 1.0.3 or newer.
#8
Building MySQL with Cygwin

I successully 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).

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 ).

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 row 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.
Eric T.
#9
Makefile should link to -lmysqlclient, not -lmysql as I previously foolishly stated. That it worked but crashed was 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.

SQL_CFLAGS=-I/usr/local/include/mysql
SQL_LDFLAGS=-L/usr/local/lib/mysql -lmysqlclient -lz -lcrypt -lm

Cheers,
Eric T.