Problems with the RubyExampleCreateLayOut

I built the ruby create layout example using the latest sketchup api API Version 5.0 in VS2015, but trying to run it in sketchup gives the following error message:

Error: #<LoadError: 126: The specified module could not be found.   - C:/Users/richard/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Plugins/CreateLayOutExample.so>
C:/Users/richard/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Plugins/createLayOut.rb:29:in `require_relative'
C:/Users/richard/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Plugins/createLayOut.rb:29:in `run'
C:/Users/richard/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Plugins/createLayOut.rb:108:in `block in <module:CreateLayOutExample>'
SketchUp:1:in `call'

The so module file does exist at that location, and I’m not really sure where to go from here. Does anyone have any ideas?

the exact loading code is critical, what do you use?
try this in Ruby Console…

require 'CreateLayOutExample'

does it return true ?

john

I get a very similar output:

require 'CreateLayOutExample'
Error: #<LoadError: 126: The specified module could not be found.   - C:/Users/richard/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Plugins/CreateLayOutExample.so>
C:/Program Files/SketchUp/SketchUp 2017/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:54:in `require'
C:/Program Files/SketchUp/SketchUp 2017/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:54:in `require'
<main>:in `<main>'
SketchUp:1:in `eval'

it may be a Ruby 2.2 issue, does it work in v16?

john

No, still the same issue

Error: #<LoadError: 126: The specified module could not be found.   - C:/Users/richard/AppData/Roaming/SketchUp/SketchUp 2016/SketchUp/Plugins/CreateLayOutExample.so>
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Program Files/SketchUp/SketchUp 2016/Tools/RubyStdLib/rubygems/core_ext/kernel_require.rb:45:in `require'
C:/Users/richard/AppData/Roaming/SketchUp/SketchUp 2016/SketchUp/Plugins/createLayOut.rb:29:in `run'
C:/Users/richard/AppData/Roaming/SketchUp/SketchUp 2016/SketchUp/Plugins/createLayOut.rb:108:in `block in <module:CreateLayOutExample>'
SketchUp:1:in `call'

I decided to double check that it actually exists, but it does.

File.file?('C:/Users/richard/AppData/Roaming/SketchUp/SketchUp 2016/SketchUp/Plugins/CreateLayOutExample.so')
true

This is the error message you’d get IF the file did not exist (or you gave the wrong path):
Error: #<LoadError: cannot load such file -- CreateLayOutExample.so>

This is not the error you are seeing. (:Jedi_mind_trick:)

(1) The C-side entry function name suffix must be the same as the library filename.

So if the filename is “CreateLayOutExample.so”, then the entry point
function name must be “Init_CreateLayOutExample()”.

This is a Ruby C extension thang, and not specific to SketchUp.


(2) Make sure the binary library’s bitness matches that of the SketchUp edition.
(You cannot load a 64-bit binary into a 32-bit Ruby subprocess, or visa versa.)


(3) Make sure you use the correct Ruby version libraries …

<2014 : v 1.8.6-p287
2014..2016 : v 2.0.0-p247
2017 : v 2.2.4-p230

… and the correct SDK libraries (for the SketchUp version and bitness.)

I actually just compiled a working extension by grabbing the ruby-c-extension-examples off the Sketchup github and checking out the dev-ruby224 branch.

As for 1, 2 and 3 I had assumed that downloading the latest SDK and compiling an example project would work. Or at least have some helpful information in the README…

Thank you for the pointers but as far as I can tell though everything you pointed out is set correctly.

I’m 99% sure my issue is that I am unfamiliar with Windows development and Visual Studio in particular. Now that I have a working setup learning should be much easier, or at least possible.

I think Thomas (@tt_su) has recently mentioned something about a tutorial on the “to do” list ?

Please see this thread which appear to be related: The SketchUpAPI & LayOutAPI 2017 SDK Bug! - #2 by tt_su

@necronian Did you ever fix the LoadError issue?

Yes I mentioned it above, I just checked out more up to date example code from github and it compiled for me. GitHub - SketchUp/ruby-c-extension-examples: Ruby C extension examples I needed to check out the dev-ruby224 branch, but I think in the intervening couple of years that branch has been merged into master.

1 Like

Ok so you created a new project, you didn’t fix the issue in the original one?

I just needed a jumping off point for my own extension & communicating with ruby. I never actually needed that specific example, especially since I believe it is up on the extension warehouse.