Using Tk or Fox with a ruby interpreter embedded in a C application

I

Ivan Muzzolini

Hi! I'm using the ruby interpreter inside a console application written
in C. I compile the C code with the freely downloadable version of the
Microsoft Compiler (Visual C++ Toolkit 2003) and the Ruby182-15 ( the
Windows Installer version).
I'm able to interact with the ruby objects using the Ruby C API and use
several ruby standard modules.
Now, I would like to insert a GUI and use tk or fox. I tried to create
a ruby module BUT the application crashes (the interpreter seems to
crash) when I put the following instructions in a ruby module:

require 'tk'

The same happens if I require 'fox12'. The interpreter doesn't emit any
error message in the standard output; I expected to have some message
because if, for instance, I call a method that is not defined I get a
message in the standard output.
The same ruby module, if launched by the command line using the
ruby.exe program works correctly.

Do you have any idea?

Thanks
Ivan
 
G

Gerald Murray

The load path variable is empty when running embedded.
Find your load path by executing something like
ruby -e 'puts $:.join("\n")'

Then check the $:[] before the require statement in the script.

Scripts that load scripts can be loaded into an embedded ruby.
But complicated libraries like tk and fxruby introduce an abundance
of problems: not finding libraries, relocation errors, undefined
methods,
etc., so there use in embedded would be very complicated compared to
running the same script of an unembedded ruby.

Gerald
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top