我正在尝试使用Ruby 1.9运行wxRuby,但是如果没有遇到段错误,我就无法启动应用程序。即使是网站上建议的小型最小应用程序(下面使用的代码)也不会运行。
require "wx"
include Wx
class MinimalApp < App
def on_init
Frame.new(nil, -1, "Test").show
end
end
MinimalApp.new.main_loop
该程序在使用ruby test.rb
运行时崩溃并显示以下消息:
ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-linux]
-- control frame ----------
c:0004 p:---- s:0009 b:0009 l:000008 d:000008 CFUNC :main_loop
c:0003 p:0066 s:0006 b:0006 l:001078 d:0007a8 EVAL test.rb:10
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:001078 d:001078 TOP
---------------------------
-- Ruby level backtrace information ----------------------------------------
test.rb:10:in `<main>'
test.rb:10:in `main_loop'
-- C level backtrace information -------------------------------------------
/home/vinny/.rvm/rubies/ruby-1.9.2-p320/lib/libruby.so.1.9(rb_vm_bugreport+0x5e) [0x7f8ae7464b9e]
/home/vinny/.rvm/rubies/ruby-1.9.2-p320/lib/libruby.so.1.9(+0x64234) [0x7f8ae7340234]
/home/vinny/.rvm/rubies/ruby-1.9.2-p320/lib/libruby.so.1.9(rb_bug+0xa5) [0x7f8ae73410c5]
/home/vinny/.rvm/rubies/ruby-1.9.2-p320/lib/libruby.so.1.9(+0x118c04) [0x7f8ae73f4c04]
/lib64/libpthread.so.0() [0x3b6e80efe0]
/lib64/libwx_baseu-2.8.so.0(_ZN7wxMutex6UnlockEv+0) [0x3b790e4390]
/lib64/libwx_gtk2u_core-2.8.so.0() [0x3b7a9e452b]
/lib64/libglib-2.0.so.0() [0x3b70047964]
/lib64/libglib-2.0.so.0(g_main_loop_run+0x72) [0x3b70047dc2]
/lib64/libgtk-x11-2.0.so.0(gtk_main+0xa7) [0x3b7b54ac57]
/lib64/libwx_gtk2u_core-2.8.so.0(_ZN11wxEventLoop3RunEv+0x48) [0x3b7a9f81d8]
/lib64/libwx_gtk2u_core-2.8.so.0(_ZN9wxAppBase8MainLoopEv+0x4c) [0x3b7aa6a30c]
/lib64/libwx_gtk2u_core-2.8.so.0(_ZN5wxApp10InitializeERiPPw+0x371) [0x3b7a9e4a41]
/lib64/libwx_baseu-2.8.so.0(_Z12wxEntryStartRiPPw+0x7e) [0x3b7909745e]
/lib64/libwx_baseu-2.8.so.0(_Z12wxInitializeiPPw+0x3c) [0x3b7909776c]
/lib64/libwx_baseu-2.8.so.0(_Z7wxEntryRiPPw+0x1a) [0x3b7909788a]
/home/vinny/.rvm/gems/ruby-1.9.2-p320/gems/wxruby-ruby19-2.0.0-x86_64-linux/lib/wxruby2.so(+0x21b403) [0x7f8ae00cb403]
/home/vinny/.rvm/rubies/ruby-1.9.2-p320/lib/libruby.so.1.9(+0x181d8c) [0x7f8ae745dd8c]
/home/vinny/.rvm/rubies/ruby-1.9.2-p320/lib/libruby.so.1.9(+0x17a142) [0x7f8ae7456142]
/home/vinny/.rvm/rubies/ruby-1.9.2-p320/lib/libruby.so.1.9(+0x17e430) [0x7f8ae745a430]
/home/vinny/.rvm/rubies/ruby-1.9.2-p320/lib/libruby.so.1.9(rb_iseq_eval_main+0xb0) [0x7f8ae7460330]
/home/vinny/.rvm/rubies/ruby-1.9.2-p320/lib/libruby.so.1.9(+0x6a59a) [0x7f8ae734659a]
/home/vinny/.rvm/rubies/ruby-1.9.2-p320/lib/libruby.so.1.9(ruby_exec_node+0x1d) [0x7f8ae73475bd]
/home/vinny/.rvm/rubies/ruby-1.9.2-p320/lib/libruby.so.1.9(ruby_run_node+0x1c) [0x7f8ae734954c]
ruby(main+0x4b) [0x40088b]
/lib64/libc.so.6(__libc_start_main+0xf5) [0x3b6e421735]
ruby() [0x4008b9]
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
Aborted (core dumped)
我已经在Ruby 1.9.3p194和1.9.2p320(上面显示的后者的日志)上尝试了这个,两者都有相同的结果。我没有在Ruby 1.8上测试过,但我不想使用1.8来运行wxRuby。
我的Ruby版本是使用RVM管理的,并且安装的wxRuby版本是2.0.0(gem name-wxruby-ruby19)(2.0.1不适用于64位Linux)。
我已经在irb中验证过可以成功使用“wx”,但是一旦运行main_loop方法,它就会崩溃。
我的操作系统是Fedora 17 x64,我安装了wxGTK 2.8.12软件包以供C ++使用,如果这样做有所不同。