From: Ryan Davis Date: 2005-05-04T17:35:06+09:00 Subject: Re: C Extensions using MingW (invalid address LoadError) On May 3, 2005, at 8:39 PM, Kian Wright wrote: > I've had some real trouble getting my first C extensions for Ruby to > link > correctly, and now they won't load into Ruby properly. > > 1) How to correctly compile and link extensions using the mingw gcc > compiler? [...] You might want to take a look at RubyInline. Experiment with simple stuff just to get a feel for it. When you want, run w/ ruby -d to see the commands and flags it is using to compile and link the inlined code. Here is a simple example I wrote earlier today to help a friend out with their code. They were coding in ObjC (really just plain C at that stage) and having problems. Popping their example into inline made all compile and link issues just melt away. I should note that I do not develop on windoze and we have had some issues in the past with mingw, but those appear to be addressed and I haven't heard about anything similar in a while. #!/usr/local/bin/ruby -w require 'inline' class Example inline(:C) do |builder| builder.c <<-'END' void myrand() { unsigned int i; srandom(0); for (i = 0; i < 100; i++) { printf("%.17Lf \t", (random() / (double) LONG_MAX )); } puts(""); } END end end Example.new.myrand -- ryand-ruby@zenspider.com - http://blog.zenspider.com/ http://rubyforge.org/projects/parsetree/ http://rubyforge.org/projects/rubyinline/ http://www.zenspider.com/seattle.rb