Mingw compilation: Here's how

I tried to build ruby-1.6.7 with Mingw-2.0.0-3 and
MSYS-1.0.8-2002.09.07-1 on a “windows me” system. I had to make these
changes to the ruby source code:

diff -ur orig/ruby-1.6.7/ext/socket/extconf.rb mingw/ruby-1.6.7/ext/socket/extconf.rb
— orig/ruby-1.6.7/ext/socket/extconf.rb 2001-12-03 10:04:46.000000000 +0000
+++ mingw/ruby-1.6.7/ext/socket/extconf.rb 2002-10-26 19:44:54.000000000 +0100
@@ -139,10 +139,14 @@
end

if try_link(<<EOF)
+#ifdef MINGW32
+#include <winsock2.h>
+#else
#include <sys/types.h>
#include <netdb.h>
#include <string.h>
#include <sys/socket.h>
+#endif
int
main()
{
diff -ur orig/ruby-1.6.7/win32/win32.c mingw/ruby-1.6.7/win32/win32.c
— orig/ruby-1.6.7/win32/win32.c 2001-11-13 08:35:06.000000000 +0000
+++ mingw/ruby-1.6.7/win32/win32.c 2002-10-25 23:16:02.000000000 +0100
@@ -24,6 +24,11 @@
#include <windows.h>
#include <winbase.h>
#include <wincon.h>

···

+#ifdef MINGW32
+#include <mswsock.h>
+#endif
+
#include “win32.h”
#include “dir.h”
#ifndef index
diff -ur orig/ruby-1.6.7/win32/win32.h mingw/ruby-1.6.7/win32/win32.h
— orig/ruby-1.6.7/win32/win32.h 2001-11-13 08:35:06.000000000 +0000
+++ mingw/ruby-1.6.7/win32/win32.h 2002-10-25 21:14:00.000000000 +0100
@@ -223,8 +223,12 @@
extern pid_t waitpid (pid_t, int *, int);
extern int do_spawn(char *);
extern int kill(int, int);
+#ifndef isinf
extern int isinf(double);
+#endif
+#ifndef isnan
extern int isnan(double);
+#endif

//

When configuring, use a prefix argument with a drive letter, and use
forward slashes as path delimiters, like this:

./configure --prefix=c:/PROGRA~1/Ruby

after that, run “make”, “make test” and “make install”. "make install"
will pause for some 30 seconds right at the beginning, don’t interrupt,
it will continue!

I also checked that this patch does not harm the cygwin, msvc6, or linux
builds.

Tobias

tpeters@invalid.uni-oldenburg.de tpeters@invalid.uni-oldenburg.de writes:

I tried to build ruby-1.6.7 with Mingw-2.0.0-3 and
MSYS-1.0.8-2002.09.07-1 on a “windows me” system. I had to make these
changes to the ruby source code:

I guess I’ve fixed. Try the latest CVS(ruby_1_6 branch) or
stable-snapshot.

···


eban

WATANABE Hirofumi wrote:

I had to make these
changes to the ruby source code:

I guess I’ve fixed. Try the latest CVS(ruby_1_6 branch) or
stable-snapshot.

Thanks for the hint. This does indeed fix the Mingw compilation.

Strange: If I configure with --enable-shared, then Mingw actually
tries to compile the curses extension (and fails because of the
missing curses header file). This does not happen if I compile without
the --enable-shared command line argument.

Tobias