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

**URL:** <https://www.ruby-forum.com/t/using-tk-or-fox-with-a-ruby-interpreter-embedded-in-a-c-appl/89065>\
**Category:** Ruby\
**Created:** [January 3, 2006, 9:28pm UTC](https://www.ruby-forum.com/t/using-tk-or-fox-with-a-ruby-interpreter-embedded-in-a-c-appl/89065 "2006-01-03T21:28:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan\_Muzzolini](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e9a140/32.png) [@Ivan\_Muzzolini](https://www.ruby-forum.com/u/Ivan_Muzzolini)\
**Post date:** [January 3, 2006, 9:28pm UTC](https://www.ruby-forum.com/t/using-tk-or-fox-with-a-ruby-interpreter-embedded-in-a-c-appl/89065/1 "2006-01-03T21:28:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ivan\_Muzzolini](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e9a140/32.png) [@Ivan\_Muzzolini](https://www.ruby-forum.com/u/Ivan_Muzzolini)\
**Post date:** [January 4, 2006, 4:34am UTC](https://www.ruby-forum.com/t/using-tk-or-fox-with-a-ruby-interpreter-embedded-in-a-c-appl/89065/2 "2006-01-04T04:34:22Z")

</div>

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
