[Win32utils-devel] Trying to get RubyInline to work with VS

Daniel Berger djberg96 at gmail.com
Fri Jun 22 01:01:16 UTC 2012


Hi,

I noticed that RubyInline did not work with Visual Studio (or mingw
for that matter). I forked RubyInline and made some patches that look
like they ought to work. Mostly it was just adjusting the build
command string so that linker options came after the -link option,
though I also changed the default extension to .dll and I make a
Dir.chdir call before the build happens so that it doesn't build in
the current directory.

https://github.com/djberg96/rubyinline

However, even after my patches I'm still having trouble. It builds,
but it won't load. I tried it with this simple bit of inline code:

# factorial.rb
require "inline"
class MyTest
  inline do |builder|
    builder.c "
      long factorial(int max) {
        int i=max, result=1;
        while (i >= 2) { result *= i--; }
        return result;
      }"
  end
end

t = MyTest.new()
p t.factorial(5)

I can see that it generated the .c code and built the .dll file in
c:\Users\djberge\.ruby_inline\ruby-1.9.1

Inline_MyTest_cb89593d1f9fe3ecdb2178215eee80ae.c
Inline_MyTest_cb89593d1f9fe3ecdb2178215eee80ae.dll

However, it fails trying to load the file:

c:/usr/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require': cannot load such file --
   C:/Users/djberge/.ruby_inline/ruby-1.9.1/Inline_MyTest_cb89593d1f9fe3ecdb2178215eee80ae.dll
(LoadError)
        from c:/usr/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
`require'
        from c:/usr/lib/ruby/gems/1.9.1/gems/RubyInline-3.11.2/lib/inline.rb:522:in
`load'
        from c:/usr/lib/ruby/gems/1.9.1/gems/RubyInline-3.11.2/lib/inline.rb:859:in
`inline'
        from factorial.rb:3:in `<class:MyTest>'
        from factorial.rb:2:in `<main>'

What have I done wrong?

Regards,

Dan


More information about the win32utils-devel mailing list