Hi everyone, I have a very weird problem to solve. I've programmed a C++ extension for a sketchup project. What I do :-I compile it with extconf & make -> it works-I test the source file on ruby console with irb and other commands -> it works-I put require 'mytest' and include CallModule at the beginning of my ruby script and I put the source file into the plugin directory with the ruby script.-I launch SketchUp and it crashes instantly.

I made a lot of test and I'm sure SketchUp crashes because of my source file .so resulting of the compilation of my cpp file "mytest.cpp". I tried to remove the line "require 'my test" at the beginning of my ruby script and sure it crashes because of source file I put in the plugin directory. Moreover I tried to make a C version of my extension and I get the same problem.

Hope you can help me because I don't know what can I do. I'm on Windows XP Pro.

Thanks for the quick reply. the problem is that i'm running it on Windows. The file you got after compiling the C extension is "Bundle" and mine a source, I don't know if there is a difference for SketchUp.I saw your topic but I don't understand how you solved your problem?

breton_nerd wrote:Hi everyone, I have a very weird problem to solve. I've programmed a C++ extension for a sketchup project. What I do :-I compile it with extconf & make -> it works-I test the source file on ruby console with irb and other commands -> it works

What Ruby version did you compile against ??

Sketchup cannot run anything in the v1.9.x Ruby trunk.

You need to compile with Ruby v1.8.6 PatchLevel 287 or higher (which is the interpreter distro'd with Sketchup 8.x)

breton_nerd wrote:I made a lot of test and I'm sure SketchUp crashes because of my source file .so resulting of the compilation of my cpp file "mytest.cpp". I tried to remove the line "require 'my test'" at the beginning of my ruby script...

The name of the C-side Init function must contain the exact so filename, with the same case: ie: Init_mytest

Speed up the require() method's file search by specifying the .so file extension. (It will skip seaching for mytest.rb and mytest.rbw, mytest.dll, etc.)

breton_nerd wrote:... and sure it crashes because of source file I put in the plugin directory.

Do not put .so files in the Plugins folder, put them in your extension subfolder.

plugins/breton_nerd/mytest/mytest.so

Users want control of what gets loaded, see the SketchupExtension class. Normally you have an extension registration script, plugins/mytest_ext.rb, in the plugins folder, and your plugin script is in a subfolder. In this example: plugins/breton_nerd/mytest/mytest_loader.rb

breton_nerd wrote:-I put require 'mytest' and include CallModule at the beginning of my ruby script and I put the source file into the plugin directory with the ruby script.-I launch SketchUp and it crashes instantly.

You should be calling:

require "breton_nerd/mytest/mytest.so"

Do not include (ie, Mix-In,) anything into Object. ONLY mixin modules into YOUR own modules or YOUR own custom classes, or by using the extend() method to mix into an existing instance object. When you use the include() method in code that is not wrapped in a module (or class) definition, you are trying to mix a module into Object.

Besides a coder's (YOUR,) TopLevel module, ONLY Ruby Base Classes and Modules should be defined at the top level, which is actually main, a special instance of class Object.

Your example above did not show that you are wrapping code within your toplevel module.

In Ruby, the include() and extend() methods, are for "mixing-in" features from a specially written module (called a "Mix-In" module,) into the current module or class, in special (and often confusing,) ways.

Ruby does not have a "paste" method (although I wish it did,) that would just simply paste the contents of a module into the current namespace from where it was called. (I am forced to write a method of my own to do that.)

breton_nerd, i use this version of ruby http://rubyforge.org/frs/download.php/4 ... 27_rc2.exe for compile C++ extension.And I comment lines//#if _MSC_VER != 1200//#error MSC version unmatch//#endifin c:\Ruby186\lib\ruby\1.8\i386-mswin32\config.hI had failed with other versions. What version of ruby you use?

exvion wrote:breton_nerd, i use this version of ruby http://rubyforge.org/frs/download.php/4 ... 27_rc2.exe for compile C++ extension.And I comment lines//#if _MSC_VER != 1200//#error MSC version unmatch//#endifin c:\Ruby186\lib\ruby\1.8\i386-mswin32\config.hI had failed with other versions. What version of ruby you use?

Yes that is Ruby version 1.8.6-p287, the version of the interpreter that Google distro'd with Sketchup 8.x;(The 27_rc2 refers to the One-Click Ruby Installer release package.)Here is the Release Notes page link.