WxRuby, Ruby 2.0, and Windows 7

I’m working on a project for the National Renewable Energy Labs,
developing a plugin for Trimble SketchUp. We are using WxRuby as the
backbone for our GUI components. We love it’s flexibility and ease of
use. Unfortunately, SketchUp recently updated from Ruby 1.8.6 to Ruby
2.0.0 and now WxRuby is incompatible with our plugin.

Has anyone had success getting WxRuby to work with Ruby 2.0 on a Windows
machine? I have downloaded the WxRuby source code, WxWidgets source
code, and SWIG, and I’ve spent a lot of effort investigating how WxRuby
works. Unfortunately, I have had no success compiling my own version to
be compatible with Ruby 2.0.0. Also, what version of WxWidgets should I
be using? Do the newer versions (e.g. WxWidgets 3.0.0) present problems
with WxRuby?

Can anyone offer any help getting WxRuby to work with Ruby 2.0.0?

Thanks!

Am 02.04.2014 22:15, schrieb Kameron Kincade:

Has anyone had success getting WxRuby to work with Ruby 2.0 on a Windows
machine?

wxRuby is currently unmaintained since several years, i.e. nobody works
on it. Unless you want to maintain wxRuby yourself, there are no
guarantees it builds on anything.

Also, what version of WxWidgets should I
be using? Do the newer versions (e.g. WxWidgets 3.0.0) present problems
with WxRuby?

wxRuby is incompatible with any wxWidgets version greater then 2.8.12.
Additionally, wxRuby AFAIK needs SWIG 1.3.x to built successfully.
wxRuby was barely compatible with Ruby 1.9, so I doubt it would work on
Ruby 2.x.

Can anyone offer any help getting WxRuby to work with Ruby 2.0.0?

A friend of mine is working on an alternative wxWidgets bridge to ruby:

Maybe you want to try that one?

Thanks!

Vale,
Quintus


Blog: http://www.quintilianus.eu

I will reject HTML emails. | Ich akzeptiere keine HTML-Nachrichten.
|
Use GnuPG for mail encryption: | GnuPG fr Mail-Verschlsselung:
http://www.gnupg.org | The GNU Privacy Guard

A friend of mine is working on an alternative wxWidgets bridge to ruby:
GitHub - Hanmac/rwx: wxWidgets binding for ruby

Maybe you want to try that one?

Thanks for the suggestion. Do you have any more information on rwx?

Some of my questions include:
Is it compatible with Ruby 2.0?
What version of WxWidgets is it compatible with and to what extent (what
widgets are not functional)?
Does it need to be built, and if so how?

I cloned the git repo, but unfortunately there are not any instructions
on how to use it. Any information you can provide would be much
appreciated. Thanks!!!

Hi i am the Author of rwx, so for your questions:

rwx should work with 1.9.3 but 2.0 is recomended, (i test it against
trunk)
wxWidgets 3.0 is current, it should work with that, and also there i
test against trunk (2.8 is not supported and i don’t know if i want
that)

there are still some widgets that does not work or are not implemented
yet
there are some samples for beginning and there is a decent rdoc
documentation

the usage is similar to wxRuby but with a bit differences (like
WX::ID_OK or what else its named in wxRuby is not a constant in rwx but
you can simply use :ok as symbol) this differences are not documented
yet in a README but might be noticeable from the samples

like i said README is currently not important, and currently i try not
to add new classes or methods and try to document the existing ones
(currently ~44% documented)

a gem can be build with rake:

rake gem
gem install *

or directly with

cd ext
ruby extconf.rb
make
[sudo] make install

PS: but i do not know what todo on a windows machine … (never had one
since years)

@Jason: what wx version did you use (what are the compile flags), what
is your Gcc/clang version
and what sample did you use and what did you do?
because i couldnt reproduce it yet

Hi,

Thanks for your work on rwx.

I followed the instruction (on Mac 10.9 using Ruby 2.1 via RVM).
Compiled OK. When I tried to run an example, got the error

ruby(1246,0x7fff7d5a8310) malloc: *** error for object 0x7fff5872feb0:
pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

i might fixed that problem with “couldn’t set to colour string ‘CYAN’”
please try it again if it works, if not i might need to fix more

Hi Hans,

I installed standard WxWidgets 3.0 for Mac.

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr
–with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix

$ruby -version
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]

The example I tried

$cd samples/controls
$ruby controls.rb

I just did git pull, and rebuild (ruby extconf.rb; make), got this
error:

~/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
require': wxColour::Set - couldn't set to colour string 'CYAN' (WX::Error) from ~/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:inrequire’
from controls.rb:2:in `’

Hi Hans,

Did update and rebuild, still got the “CYAN” error.

~/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
require': wxColour::Set - couldn't set to colour string 'CYAN' (WX::Error) from ~/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:inrequire’
from controls.rb:2:in `’

i fixed the color bug … the bad thing is that the constants are only
later available

hm what i think the problem might be, try to use a newer gcc version or
use a newer clang version, i dont know about homebrew but this should
be easly installed with macports (the gcc4.2 version from mac might be
buggy)

rvm does help to recompile ruby after changing the CC (because even with
newer gcc or newer clang it still prefers the system installed version)

and PS: if you try this, all, wxwidgets, ruby and this gem need to be
compiled with the same version so mixing clang & gcc does not work

Hi Hans,

The ‘CYAN’ issue is fixed. I ran controls.rb under samples/controls, got
the error. I am using fresh-installed Mac OS X 10.9, given rwx was
working for you, the only thing I can think of : I installed homebrew.

ruby(3099,0x7fff75122310) malloc: *** error for object 0x7fff5c9e7e50:
pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

PS also try wxtrunk, the packaged version from wx might be buggy

Jason S. [email protected] writes:

ruby(3099,0x7fff75122310) malloc: *** error for object 0x7fff5c9e7e50:
pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

To help Hans debugging the problem, you might want to run your program
in a GDB session like this:

$ gdb ruby

r yourscript.rb
(wait until it aborts)
bt

This will give you a backtrace that exactly shows where the code
crashes. You will need to have compiled rwx in debug mode for this.
Note I’m not a rwx dev, just throwing in a random suggestion here.

Vale,
Quintus


Blog: http://www.quintilianus.eu

I will reject HTML emails. | Ich akzeptiere keine HTML-Nachrichten.
|
Use GnuPG for mail encryption: | GnuPG für Mail-Verschlüsselung:
http://www.gnupg.org | The GNU Privacy Guard

Thanks for the responses.

Tried, GDB approach, no stack returned.

(gdb) r controls.rb
Starting program: ~/.rvm/rubies/ruby-2.1.1/bin/ruby controls.rb
Unable to find Mach task port for process-id 32174: (os/kern) failure
(0x5).
(please check gdb is codesigned - see taskgated(8))
(gdb) bt
No stack.

Then I use rvm to use system Ruby (ruby 2.0.0p247) to compile rwx. Got
four errors as the below:

wxAboutDlg.cpp:68:2: error: use of undeclared identifier ‘RARRAY_AREF’
set_option2(version,Version)
^

Can you point me some instructions on wxtrunk? thanks.

Hi Hans,

The RARRAY_AREF is fixed, got this compilation error (rvm use system
ruby on Mac OS 10.9)

wxBookCtrl.cpp:126:2: error: no matching function for call to
‘rb_enumeratorize_with_size’
RETURN_SIZED_ENUMERATOR(self,0,NULL,_each_size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/intern.h:217:13:
note:
expanded from macro ‘RETURN_SIZED_ENUMERATOR’
return rb_enumeratorize_with_size((obj),
ID2SYM(rb_frame_this_func()),
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/intern.h:214:7:
note:
candidate function not viable: no known conversion from ‘VALUE
(VALUE)’ to ‘VALUE (*)(…)’ for
5th argument
VALUE rb_enumeratorize_with_size(VALUE, VALUE, int, VALUE , VALUE
(
)(ANYARGS));
^
1 error generated.
make: *** [wxBookCtrl.o] Error 1

fixed problem with RARRAY_AREF … it was because of i only test against
newer versions … (currenlty does not have a working system there)

with wxtrunk i mean try to compile from there

so, should be fixed with RUBY_METHOD_FUNC … funny that it seems
unnecessary on my system

Hi,

I still experienced the same error.

wxBookCtrl.cpp:126:2: error: no matching function for call to
‘rb_enumeratorize_with_size’
RETURN_SIZED_ENUMERATOR(self,0,NULL,_each_size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/intern.h:217:13:
note:

sorry i had an error with unmerged code i didn’t noticed yet,
i fixed it and added 26 new commits yesterday