Problem on C ruby extension

hi all:
i have some functions already in c, and want to provide ruby interfaces that can be used in sketchup 2014’s ruby console. os is win7
what i am done:

  • download ruby source code : ruby-2.0.0-p247.tar.bz2
  • compile it use vs 2008 x86,
  • wrap my c functions, and write a extconf.rb
  • use ruby-2.0.0-p247/build/bin/ruby.exe extconf.rb to generate a dll ( ext_ruby.so )
  • ruby-2.0.0-p247/build/bin/irb
    require ‘somepath/ext_ruby’ work

but when load ext_ruby.so in sketchup’s console.
it compains error 126.
and copy msvcr90-ruby200.dll to c:/program files(x86)/sketchup/sketchup2014 folder
it complains incompatible library version

so, some one give me a direction ? or there have a tutorial do the same thing ?
many thanks

solved by using correct ruby library

Hi!
I’ve written a C program which runs good as an exe, and would like to create a Sketchup Extension from it… I’ve tried to start with the github HelloWorld project, but did not manage to create the appropriate rb file to get it work… I recieve an error message:

Error: 193: %1 ist keine zulässige Win32-Anwendung. - path of .so file
which means “is no valid” Win-32 application…

what did I do wrong?

see also:

Make sure you are compiling the appropriate target for your machine - Win32 or 64 bit.

Thanks Jim,
In fact I’m able to run the exe file even from ruby console in SU with “system”, but I’d like to go a step further…
… to be able to “require” the compiled executable and to run a specific command in it. (and passing arguments like in the su_create_layout_file extension…)
I’m not a “real software engineer”, so it might still be that your hint to win32 and win64 is correct…

This may be the base of your problem. You can “require” a Ruby or a compiled Ruby extension dll, you can’t “require” an .exe.

this point is clear!
BUT
how to get a VisualStudio Project converted to a compiled ruby extension???

I thought to learn it by

but if I compile that project, and try by require, I get the above error message…

I’m on a Mac, so I’ll have to defer to a Windows expert regarding Visual Studio setup to compile a Ruby extension dll vs an executable .exe.

Thanks for contributions - pls follow the discussion at:

(if interested :slight_smile:

I am having issues with incompatible library version within Sketchup 2017 too:

Error Loading File /Users/***/Library/Application Support/SketchUp 2017/SketchUp/Plugins/MyPlugin/core.rb
Error: #<fatal: incompatible library version - /Users/***/Library/Application Support/SketchUp 2017/SketchUp/Plugins/MyPlugin/SUEX_MyPlugin.bundle>
/Applications/SketchUp 2017/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Applications/SketchUp 2017/SketchUp.app/Contents/Frameworks/Ruby.framework/Versions/2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'

I can run my plugin for SU2016 with Ruby 2.0, but I can’t get past the error above with SU2017. I am using Ruby 2.0 Framework for SU2016, and Ruby 2.2 for SU2017. I have tried as much as possible to emulate the settings and use files from this project: GitHub - SketchUp/ruby-c-extension-examples: Ruby C extension examples

… but no luck. I think I really need help!