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

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?


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
etc., so there use in embedded would be very complicated compared to
running the same script of an unembedded ruby.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs