Building Ruby extension on Win32

Official forum for the Chipmunk2D Physics Library.
Post Reply
alexg
Posts: 4
Joined: Mon Sep 10, 2007 7:02 am
Contact:

Building Ruby extension on Win32

Post by alexg »

Hi,

Just wondering if anyone had successfully built the Ruby extension under Win32. I've been using Chipmunk on OSX and am really impressed, but having a Win32 version would be a great help as well.

I'm using the One-Click installer for Ruby and have tried compiling under MinGW and MSVS8. Using MinGW I run into problems with the Makefile generated - since Ruby generates an nmake compatible makefile which the MinGW make (gnu make) cannot understand. I managed to compile each file by hand using gcc, but ran out of luck at the linking stage. I can give the errors I got here if needed.

Under MSVS8 the Makefile parses fine but CL.exe complains at compilation (this is using the version I downloaded from slembke's last post in the other Win32 build thread):

http://www.slembcke.net/forums/viewtopi ... a&start=10

I've edited the Makefile to make CL compile as C++ rather than C, which gives less errors but maybe isn't the right way forward. Here is the nmake/CL output:

Code: Select all

E:\Microsoft Visual Studio 8\PSDK\ChipmunkMSVC\ruby>nmake

Microsoft (R) Program Maintenance Utility Version 8.00.50727.762
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl -nologo -I. -Ie:/ruby/lib/ruby/1.8/i386-mswin32 -Ie:/ruby/lib/ruby/1.
8/i386-mswin32 -I. -MD -Zi -O3b2xg- -G6 -std=gnu99  -c -Tprb_chipmunk.c
cl : Command line warning D9035 : option 'Og-' has been deprecated and will be r
emoved in a future release
cl : Command line warning D9002 : ignoring unknown option '-O3'
cl : Command line warning D9002 : ignoring unknown option '-G6'
cl : Command line warning D9002 : ignoring unknown option '-std=gnu99'
rb_chipmunk.c
e:\microsoft visual studio 8\psdk\chipmunkmsvc\ruby\rb_chipmunk.h(39) : error C2
440: 'initializing' : cannot convert from 'void *' to 'cpVect *'
        Conversion from 'void*' to pointer to non-'void' requires an explicit ca
st
rb_chipmunk.c(69) : error C2057: expected constant expression
rb_chipmunk.c(69) : error C2466: cannot allocate an array of constant size 0
rb_chipmunk.c(69) : error C2133: 'verts' : unknown size
rb_chipmunk.c(93) : error C2664: 'rb_define_module_function' : cannot convert pa
rameter 3 from 'VALUE (__cdecl *)(VALUE)' to 'VALUE (__cdecl *)(...)'
        None of the functions with this name in scope match the target type
rb_chipmunk.c(94) : error C2664: 'rb_define_module_function' : cannot convert pa
rameter 3 from 'VALUE (__cdecl *)(VALUE,VALUE)' to 'VALUE (__cdecl *)(...)'
        None of the functions with this name in scope match the target type
rb_chipmunk.c(95) : error C2664: 'rb_define_module_function' : cannot convert pa
rameter 3 from 'VALUE (__cdecl *)(VALUE)' to 'VALUE (__cdecl *)(...)'
        None of the functions with this name in scope match the target type
rb_chipmunk.c(96) : error C2664: 'rb_define_module_function' : cannot convert pa
rameter 3 from 'VALUE (__cdecl *)(VALUE,VALUE)' to 'VALUE (__cdecl *)(...)'
        None of the functions with this name in scope match the target type
rb_chipmunk.c(98) : error C2664: 'rb_define_module_function' : cannot convert pa
rameter 3 from 'VALUE (__cdecl *)(VALUE,VALUE,VALUE,VALUE,VALUE)' to 'VALUE (__c
decl *)(...)'
        None of the functions with this name in scope match the target type
rb_chipmunk.c(99) : error C2664: 'rb_define_module_function' : cannot convert pa
rameter 3 from 'VALUE (__cdecl *)(VALUE,VALUE,VALUE,VALUE)' to 'VALUE (__cdecl *
)(...)'
        None of the functions with this name in scope match the target type
rb_chipmunk.c(101) : error C2664: 'rb_define_module_function' : cannot convert p
arameter 3 from 'VALUE (__cdecl *)(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VAL
UE,VALUE)' to 'VALUE (__cdecl *)(...)'
        None of the functions with this name in scope match the target type
NMAKE : fatal error U1077: '"E:\Microsoft Visual Studio 8\VC\BIN\cl.EXE"' : retu
rn code '0x2'
Stop.
My experience with building on Windows is very slim so I'm going to keep playing around, but if anyone has already done this and has any pointers I'd be very grateful. Even just a pointer as to which way (MinGW or MSVS) is likely to be easier would be appreciated.

AlexG
alexg
Posts: 4
Joined: Mon Sep 10, 2007 7:02 am
Contact:

Re: Building Ruby extension on Win32

Post by alexg »

OK, here's my effort under MinGW. It complains about WinMain@16 missing, which makes me think I'm missing something basic:

Code: Select all

$ gcc *.c -o chipmunk.so -lmsvcrt-ruby18 -luser32 -lws2_32 -ladvapi32 -lmingw32 -mwindows -Le:/ruby/lib -Ie:/ruby/lib/ruby/1.8/i386-mswin32 -std=gnu99
cpPolyShape.c:127:2: warning: no newline at end of file
In file included from e:/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:718,
                 from rb_chipmunk.c:24:
e:/ruby/lib/ruby/1.8/i386-mswin32/missing.h:71:1: warning: "isinf" redefined
In file included from e:/ruby/lib/ruby/1.8/i386-mswin32/win32/win32.h:64,
                 from e:/ruby/lib/ruby/1.8/i386-mswin32/defines.h:183,
                 from e:/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:37,
                 from rb_chipmunk.c:24:
e:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/math.h:346:1: warning: this is the location of the previous definition
In file included from e:/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:718,
                 from rb_cpBB.c:24:
e:/ruby/lib/ruby/1.8/i386-mswin32/missing.h:71:1: warning: "isinf" redefined
In file included from e:/ruby/lib/ruby/1.8/i386-mswin32/win32/win32.h:64,
                 from e:/ruby/lib/ruby/1.8/i386-mswin32/defines.h:183,
                 from e:/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:37,
                 from rb_cpBB.c:24:
e:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/math.h:346:1: warning: this is the location of the previous definition
In file included from e:/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:718,
                 from rb_cpBody.c:24:
e:/ruby/lib/ruby/1.8/i386-mswin32/missing.h:71:1: warning: "isinf" redefined
In file included from e:/ruby/lib/ruby/1.8/i386-mswin32/win32/win32.h:64,
                 from e:/ruby/lib/ruby/1.8/i386-mswin32/defines.h:183,
                 from e:/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:37,
                 from rb_cpBody.c:24:
e:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/math.h:346:1: warning: this is the location of the previous definition
In file included from e:/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:718,
                 from rb_cpJoint.c:24:
e:/ruby/lib/ruby/1.8/i386-mswin32/missing.h:71:1: warning: "isinf" redefined
In file included from e:/ruby/lib/ruby/1.8/i386-mswin32/win32/win32.h:64,
                 from e:/ruby/lib/ruby/1.8/i386-mswin32/defines.h:183,
                 from e:/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:37,
                 from rb_cpJoint.c:24:
e:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/math.h:346:1: warning: this is the location of the previous definition
In file included from e:/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:718,
                 from rb_cpShape.c:24:
e:/ruby/lib/ruby/1.8/i386-mswin32/missing.h:71:1: warning: "isinf" redefined
In file included from e:/ruby/lib/ruby/1.8/i386-mswin32/win32/win32.h:64,
                 from e:/ruby/lib/ruby/1.8/i386-mswin32/defines.h:183,
                 from e:/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:37,
                 from rb_cpShape.c:24:
e:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/math.h:346:1: warning: this is the location of the previous definition
In file included from e:/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:718,
                 from rb_cpSpace.c:24:
e:/ruby/lib/ruby/1.8/i386-mswin32/missing.h:71:1: warning: "isinf" redefined
In file included from e:/ruby/lib/ruby/1.8/i386-mswin32/win32/win32.h:64,
                 from e:/ruby/lib/ruby/1.8/i386-mswin32/defines.h:183,
                 from e:/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:37,
                 from rb_cpSpace.c:24:
e:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/math.h:346:1: warning: this is the location of the previous definition
In file included from e:/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:718,
                 from rb_cpVect.c:24:
e:/ruby/lib/ruby/1.8/i386-mswin32/missing.h:71:1: warning: "isinf" redefined
In file included from e:/ruby/lib/ruby/1.8/i386-mswin32/win32/win32.h:64,
                 from e:/ruby/lib/ruby/1.8/i386-mswin32/defines.h:183,
                 from e:/ruby/lib/ruby/1.8/i386-mswin32/ruby.h:37,
                 from rb_cpVect.c:24:
e:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/math.h:346:1: warning: this is the location of the previous definition
/mingw/lib/libmingw32.a(main.o):main.c:(.text+0x104): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
alexg
Posts: 4
Joined: Mon Sep 10, 2007 7:02 am
Contact:

Re: Building Ruby extension on Win32

Post by alexg »

I was missing something basic - not specifying I wanted a shared library. Now with shared enabled I get a new error:

Code: Select all

$ gcc *.c -o chipmunk.so -g -O2 -Le:/ruby/lib -Ie:/ruby/lib/ruby/1.8/i386-mswin32 -std=gnu99 -lmsvcrt-ruby18 -shared
[...Warnings deleted...]
Cannot export msvcrt-ruby18_NULL_THUNK_DATA: symbol not found
collect2: ld returned 1 exit status
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Building Ruby extension on Win32

Post by slembcke »

Sounds like the Shattered Ruby guy was able to do it. You might want to PM him perhaps.
http://www.slembcke.net/forums/viewtopic.php?f=6&t=9
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
alexg
Posts: 4
Joined: Mon Sep 10, 2007 7:02 am
Contact:

Re: Building Ruby extension on Win32

Post by alexg »

Thanks. Their .so seems to work fine with the One-Click installer so I'm on my way. :)
mr_luc
Posts: 4
Joined: Fri Oct 19, 2007 12:47 pm
Contact:

Re: Building Ruby extension on Win32

Post by mr_luc »

Ack!

Sorry to bother anyone here, but ... the ShatteredRuby people apparently forgot to pay their DNS, and nothing they host, including the .so, is available!

Is there anyone who downloaded and has the .so? I'd love to be able to get (even a dated) version of it to play around with. If anyone has it ... err, they could always send it to me by email; check my profile.

I have nothing to offer in return other than naming rights for potential future offspring.
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests