Forum: wxRuby Problems installing/running svn-code

Fdd001999da2940e22e08a7af6a8d697?d=identicon&s=25 Jonathan Maasland (Guest)
on 2007-11-28 18:00
(Received via mailing list)
Hi,

The last couple of days I've been trying to get back on the wxRuby-horse
however I've ran into some problems while compiling/testing the
subversion sources. Mind, the 1.9.2 official release works fine.
Absolutely no problems whatsoever.

The first hurdle was that the rake install target doesn't work. It fails
on rakewx.rb:145. Looking into it I found that $target_lib wasn't set to
anything. Searching the sources I couldn't find where it is supposed to
be set.

Still the rake gem command works fine so I installed the newly created
gem. However when trying to run the minimal sample (only one I tried) it
segfaults. After recompiling both wxGTK and wxRuby with debug enabled I
decided to run it through gdb.

I couldn't find anything, it's just a wee bit too complex for me to
handle right now. Don't think this is useful for the developers but just
in case it might be this is the error I got: undefined symbol:
_Z10wxOnAssertPKwiPKcS0_S0_

I am running wxGTK-2.8.6, Ruby 1.8.6, RubyGems 0.9.4 and the wxruby
subversion archive is up-to-date (rev 1450). I compiled wxGTK with the
following configure command:
./configure --disable-shared --with-gtk --enable-monolithic \
 --enable-unicode --enable-debug --enable-catch_segvs
--enable-graphics_ctx \
 --enable-mediactrl --with-opengl --with-libjpeg=builtin
--with-libpng=builtin \
 --with-libtiff=builtin --with-zlib=builtin --with-expat=builtin
--enable-gui  \
 --enable-xrc --enable-mdi --enable-gif \
 --enable-pcx --enable-iff --enable-pnm --enable-xpm


With kind regards,
Jonathan Maasland
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2007-12-08 11:51
(Received via mailing list)
Hi Jonathan

Thanks for the reports, sorry to be slow in following up.

Jonathan Maasland wrote:
> The first hurdle was that the rake install target doesn't work. It fails
> on rakewx.rb:145. Looking into it I found that $target_lib wasn't set to
> anything. Searching the sources I couldn't find where it is supposed to
> be set.
>
Should now be fixed in SVN. With most people using gems, we've kind of
slipped on maintenance of the tar.gz/install route, so please do report
any probs.
> I couldn't find anything, it's just a wee bit too complex for me to
> handle right now. Don't think this is useful for the developers but just
> in case it might be this is the error I got: undefined symbol:
> _Z10wxOnAssertPKwiPKcS0_S0_
>
Hmm, I think I've seen that error if I've mistakenly compiled a debug
wxRuby against a release wxWidgets, or vice versa. I think all the
object files in wxRuby need to have been compiled with the
"WXRUBY_DEBUG" environment variable set.

The configuration for wxWidgets looks appropriate for this.

cheers
alex
3396e4a3df8a840faec520af8555a400?d=identicon&s=25 Mario Steele (Guest)
on 2007-12-11 00:00
(Received via mailing list)
Hello Jonathan,

I've ran into the same problem myself, compiling from SVN on Linux,
using
wxGTK, and Ruby 1.8.6.  I was able to get wxRuby and wxGTK to compile
with
Debug support, and from what I can see, running through gdb (Which was a
trick and a half), it shows that it's segfaulting on rb_hash_aref(),
which
is comming from /usr/lib/libruby.so.1.8  So I have a couple of questions
for
you.

1.) Which Distro are you using?

2.) Did you install Ruby from Source, or from your Distro's Package
Manager?

3.) Do you have the same problems if you take out the --with-opengl?

These are just a few questions / ideas to get an idea of where the
problem
lies.

L8ers,

Mario Steele
Fe061a5e90b738e88623292d7d2084d2?d=identicon&s=25 Eric Rubin (erubin)
on 2007-12-12 19:00
(Received via mailing list)
I've put together a GUI with WxRuby that works fine (under Windows XP).
Now
I'm adding another component, a UDP server, which runs in a separate
thread.
What I'm seeing is that the UDP server runs for a little while when I do
something in the GUI, but then stops processing UDP packets until I do
something else on the GUI.  My UDP server thread spends most of its time
waiting for a UDP packet, so it should be able to run at a high priority
without interfering with the GUI operation.



So what do I need to know about the interaction between WxRuby and other
Ruby threads?  Does WxRuby have threads running to implement GUI events?
Are there known problems with running other threads in a WxRuby app?



Thanks,

Eric Rubin
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2007-12-12 19:12
(Received via mailing list)
Hi Eric

Eric Rubin wrote:
> other Ruby threads? Does WxRuby have threads running to implement GUI
> events? Are there known problems with running other threads in a
> WxRuby app?
>

As with other GUI toolkits, wxRuby doesn't play so well with Ruby 1.8's
lightweight threads. The main GUI event loop runs constantly, and when
it's in there (in C-based code) Ruby's thread scheduler won't switch
execution to subsidiary threads.

Fortunately, it's not hard to work around by using a Wx::Timer to
schedule switches of Ruby's thread execution. The recommended workaround
is described here:

http://rubyforge.org/pipermail/wxruby-users/2007-A...

You will probably want to tweak the parameter to Timer#start to get the
best responsiveness off your UDP server whilst still keeping the GUI
reactive.

hth
alex
3396e4a3df8a840faec520af8555a400?d=identicon&s=25 Mario Steele (Guest)
on 2007-12-12 19:33
(Received via mailing list)
Hello Eric,

As pointed out by Alex, it is a bit of a side trip to get things to work
properly for wxRuby, with Ruby's Soft-Threading control.  As mentioned
above, Timer + Thread.pass is the best method in which to do this.  You
should be able to find in the SVN an example of a wxRuby program
utilizing
Sockets within Threads, that I created myself.
http://wxruby.rubyforge.org/svn/trunk/wxruby2/samp... is the
url to
the svn lookup, and you should look at wxServer.rb.  This is geared for
Connection Based sockets, not Connectionless Sockets like what your
Implementing.  I would actually like to look at your code, once you've
implemented the Timer + Thread.pass, to get an Idea of how UDP Sockets
would
work with the method, so that I can further investigate creating a
library
that will do this for us.

Thanks,

Mario Steele
Fe061a5e90b738e88623292d7d2084d2?d=identicon&s=25 Eric Rubin (erubin)
on 2007-12-13 16:07
(Received via mailing list)
Alex's fix did the trick.  Thanks.



Here's the relevant part of my code.  The UDP server, VIP102Comm, has to
receive on a multicast address.  I found some code for this online, but
had
to make a couple of changes to get it to run under Windows.  One is that
Socket::IP_ADD_MEMBERSHIP is not defined in Windows.  Also in Windows
the
setsockopt call has to come after the bind call.  (It the code I copied
it
came before and produced an error.)



There also seems to be a problem with recvfrom.  (Don't know if it's
only in
Windows.)  When I used recvfrom it worked, but each recvfrom call took
about
5 seconds.  The problem went away when I switched to recv (but now I
can't
get the source IP address).



Eric



require "soft_phone_frame"

require "vip102comm"



class SoftPhoneApp < App

  def on_init

    tmr = Wx::Timer.new(self, 55)

    evt_timer(55) { Thread.pass }

    tmr.start(100)

    frame = SoftPhoneFrame.new()

    Thread.new { VIP102Comm.new(frame) }

  end

end



SoftPhoneApp.new.main_loop





class VIP102Comm

  def initialize(parent)

    Thread.current.priority = 100

    @parent = parent  # soft_phone_frame

    @control_addr = "239.1.1.2"

    @control_port = 4097

    begin

      ip = IPAddr.new(@control_addr).hton + IPAddr.new("0.0.0.0").hton

      @sock = UDPSocket.new

      @sock.bind(Socket::INADDR_ANY, @control_port) # in Windows
setsockopt
must follow bind

      if Socket::const_defined?('IP_ADD_MEMBERSHIP')

        @sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP,
ip)

      else  # workaround for Ruby bug where Socket::IP_ADD_MEMBERSHIP is
not
defined in Windows

        @sock.setsockopt(Socket::IPPROTO_IP, 12, ip)

      end

    rescue ArgumentError => a

      puts "Argument error: " + a

    rescue Exception => e

      puts "error: " + e

    end

    loop do

      packet = @sock.recv(1350)

#      packet, sender = @sock.recvfrom(1350)

#      srcIPAddr = sender[3]

      process_packet(packet)

    end

  end
This topic is locked and can not be replied to.