Tips for compiling libraries for use with Windows Ruby?

I am planning on compiling a few libraries for use with the windows
installer of Ruby & also apache (eRuby & mod_ruby).

I don’t have VC++, so I was planning on using either mingw, mingw cross
compiler for using cygwin or borland.

I was wondering if there was any tips / pointers to prevent any binary
incompatabilities? Should it work, or will there be issues or things to
be aware of?

Rob

I don’t understand the middle paragraph, but mingw is supposed to
produce binaries that are compatible with the native Windows
installation of Ruby.

Gavin

···

On Monday, January 20, 2003, 11:38:54 PM, Robert wrote:

I am planning on compiling a few libraries for use with the windows
installer of Ruby & also apache (eRuby & mod_ruby).

I don’t have VC++, so I was planning on using either mingw, mingw cross
compiler for using cygwin or borland.

I was wondering if there was any tips / pointers to prevent any binary
incompatabilities? Should it work, or will there be issues or things to
be aware of?

I don’t have VC++, so I was planning on using either mingw, mingw cross
compiler for using cygwin or borland.

I don’t understand the middle paragraph, but mingw is supposed to
produce binaries that are compatible with the native Windows
installation of Ruby.

Really? Excellent!

Um, as to the middle paragraph I screwed up. I find it much easier to
edit other peoples text :slight_smile:

I had meant that I was thinking about using 1 of 3 options. Mingw
itself, Borlands C/C++ compiler or use cygwins gcc compiler which can be
used to generate mingw binaries.

Make more sense?

Rob

Yep. I’d be very interested to know if cygwin’s gcc can be shoehorned
to generate Windows-compatible binaries. How do you get it to
generate mingw binaries?

I think there’s an issue beyond mere object code, and that’s
libraries. But I’d like to experiment.

Gavin

···

On Tuesday, January 21, 2003, 1:05:22 AM, Robert wrote:

I don’t have VC++, so I was planning on using either mingw, mingw cross
compiler for using cygwin or borland.

I don’t understand the middle paragraph, but mingw is supposed to
produce binaries that are compatible with the native Windows
installation of Ruby.

Really? Excellent!

Um, as to the middle paragraph I screwed up. I find it much easier to
edit other peoples text :slight_smile:

I had meant that I was thinking about using 1 of 3 options. Mingw
itself, Borlands C/C++ compiler or use cygwins gcc compiler which can be
used to generate mingw binaries.

Make more sense?

Yep. I’d be very interested to know if cygwin’s gcc can be shoehorned
to generate Windows-compatible binaries. How do you get it to
generate mingw binaries?

I need to look at my notes I used when I compiled a mingw version of
ruby for a test.

If you have the mingw libs installed using cygwins setup.exe, you can
specify to gcc

-mno-cygwin

which tells it to build a windows compatible binary.

Then I believe when wanting to create a dll use

dllwrap --target=mingw

If using configure (say for building ruby as a mingw exe) I believe you
specify

–host=mingw32 --target=mingw32

I think there’s an issue beyond mere object code, and that’s
libraries. But I’d like to experiment.

Good luck

Rob

Gavin Sinclair gsinclair@soyabean.com.au writes:

Yep. I’d be very interested to know if cygwin’s gcc can be shoehorned
to generate Windows-compatible binaries. How do you get it to
generate mingw binaries?

% ./configure --with-gcc=‘gcc -mno-cygwin’ --enable-shared
% make

···


eban

Yep. I’d be very interested to know if cygwin’s gcc can be shoehorned
to generate Windows-compatible binaries.

What do you mean Windows-compatible binaries? If you mean ruby extensions,
then it’s trivial to create them using gcc; however, you have to have the
cygwin ruby installed rather than the one-click installer. Once you have
cygwin and cygwin/ruby installed, it’s just a matter of using extconf.

$ cat extconf.rb
require ‘mkmf’
create_makefile(“Test”)

$ ruby extconf.rb
$ make

make install

And that’s it, gcc has been “shoehorned” into creating a ruby C-extension
under windows.

I think there’s an issue beyond mere object code, and that’s
libraries. But I’d like to experiment.

I’ve had a number of issues turning non-trivial C libraries into DLLs using
gcc under windows. For my last project, I ended up dropping the DLL idea and
just compiling my library to object code because I was having too many problems.

One last thing. On the issue of compiler compatability, I was recently bitten
by the fact that some versions of VC++ don’t support variable length arrays,
so I would reccomend avoiding using them if you plan on people compiling
your library using VC++. I’m talking about the situation where you have
something to the effect of.

char buffer[size+1]; // breaks on some versions of VC++

Cheers,
Travis Whitton whitton@atlantic.net

Sorry, I should have been clearer. By “Windows-compatible binaries” I
meant compiling extensions that work with the
one-click-Windows-installer, which was compiled with VC++, and is
therefore not compatible with binaries produces by standard Cygwin
gcc.

I do use Cygwin Ruby, so compiling extensions for that is not a
problem. But Cygwin Ruby can’t do everything on Windows (e.g. Fox).
Or if it can, it doesn’t seem natural to me to pursue that path.

But since Cygwin is an excellent set of tools and a good Unix-like
interface, if it could be ‘shoehorned’ into compiling extensions that
work with native-Windows-Ruby, that would be a pleasant solution.

I reckon an equally pleasant solution would be to set up a full mingw
environment, but there’s no easy way to do that, especially not
compared with the Cygwin installer, which hopefully Ruby package
managers will look like one day!

Gavin

···

On Tuesday, January 21, 2003, 9:14:42 AM, Travis wrote:

Yep. I’d be very interested to know if cygwin’s gcc can be shoehorned
to generate Windows-compatible binaries.

What do you mean Windows-compatible binaries? If you mean ruby extensions,
then it’s trivial to create them using gcc; however, you have to have the
cygwin ruby installed rather than the one-click installer. Once you have
cygwin and cygwin/ruby installed, it’s just a matter of using extconf.