# wxRuby & RubyScript2exe

**URL:** <https://www.ruby-forum.com/t/wxruby-rubyscript2exe/133112>\
**Category:** wxRuby\
**Created:** [March 27, 2008, 9:51pm UTC](https://www.ruby-forum.com/t/wxruby-rubyscript2exe/133112 "2008-03-27T21:51:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Webb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/65b543/32.png) [@Matthew\_Webb](https://www.ruby-forum.com/u/Matthew_Webb)\
**Post date:** [March 27, 2008, 9:51pm UTC](https://www.ruby-forum.com/t/wxruby-rubyscript2exe/133112/1 "2008-03-27T21:51:31Z")

</div>

I’ve got wxruby (1.9.5) & rubyscript2exe (0.5.3) installed & I’m using  
Windows Vista.

I’m trying to use rubyscript2exe to turn one of the wxruby sample  
programs  
into an .exe.

The sample is in the controls folder & is called controls.rb.

I use ‘rubyscript2exe controls.rb --rubyscript2exe-verbose’ to “compile”  
it.

But when I try to run it I get the following error:

Bitmap file does not exist:  
C:\Users\Matthew\eee\eee.controls.exe.4\app/icons/list.xpm  
(ArgumentError)

Do you have any ideas how I could solve this problem?

---

<div class="post-metadata">

**Author:** ![Matthew\_Webb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/65b543/32.png) [@Matthew\_Webb](https://www.ruby-forum.com/u/Matthew_Webb)\
**Post date:** [March 28, 2008, 12:59am UTC](https://www.ruby-forum.com/t/wxruby-rubyscript2exe/133112/2 "2008-03-28T00:59:47Z")

</div>

Matthew Webb wrote:

> But when I try to run it I get the following error:
> 
> Bitmap file does not exist:  
> C:\Users\Matthew\eee\eee.controls.exe.4\app/icons/list.xpm (ArgumentError)  
> The problem is that the bitmap file isn’t included in the bundled-up  
> package that rubyscript2exe creates and later unpacks when the .exe is  
> run.

The simple way is to manually tell rubyscript2exe to add the .xpm file  
to the bundle. To do this, add a constant to the beginning of the file  
with an array of files that should be included.

RUBYSCRIPT2EXE.dlls = [‘icons/list.xpm’, …]

(Or it might be RUBYSCRIPT2EXE.libs = […]  
I can’t remember and can’t test it right now. See  
[http://www.erikveen.dds.nl/rubyscript2exe/#3.3.1](http://www.erikveen.dds.nl/rubyscript2exe/#3.3.1) )

A more complex but perhaps better way for bigger apps is to build the  
.exe as normal, then distribute it and the icons packaged up as a zip, a  
tar, or using an installer like NSIS.

Then, at runtime, test if the application is running from within  
rubyscript2exe, find out where it’s installed, and load image files from  
that location. Wx::ArtProvider can also help here. An example of this  
approach below - see the part where it sets WEFT\_SHAREDIR

[http://weft-qda.rubyforge.org/svn/trunk/weft-qda/weft-qda.rb](http://weft-qda.rubyforge.org/svn/trunk/weft-qda/weft-qda.rb)

alex

---

<div class="post-metadata">

**Author:** ![Matthew\_Webb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/65b543/32.png) [@Matthew\_Webb](https://www.ruby-forum.com/u/Matthew_Webb)\
**Post date:** [March 28, 2008, 6:19am UTC](https://www.ruby-forum.com/t/wxruby-rubyscript2exe/133112/3 "2008-03-28T06:19:28Z")

</div>

Alex F. wrote:

> > I use ‘rubyscript2exe controls.rb --rubyscript2exe-verbose’ to  
> > The simple way is to manually tell rubyscript2exe to add the .xpm file  
> > .exe as normal, then distribute it and the icons packaged up as a zip, a

It would seem that the problem isn’t ‘list.xpm’ not loading but  
‘mondrian.ico’ not loading.

I’ve added the following two lines to the beginning of ‘controls.rb’…

require “rubyscript2exe”  
RUBYSCRIPT2EXE.bin = [“mondrian.ico”]

When I run the .exe I get this error…

Icon file does not exist:  
C:\Users\Matthew\eee\eee.controls.exe.2\app/mondrian.ico (ArgumentError)

It’s really strange because ‘mondrian.ico’ is in the same folder as  
‘Controls.rb’ so I’d expect it to be found.

---

<div class="post-metadata">

**Author:** ![Matthew\_Webb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/65b543/32.png) [@Matthew\_Webb](https://www.ruby-forum.com/u/Matthew_Webb)\
**Post date:** [March 28, 2008, 7:53am UTC](https://www.ruby-forum.com/t/wxruby-rubyscript2exe/133112/4 "2008-03-28T07:53:28Z")

</div>

Matthew Webb wrote:

> Icon file does not exist:  
> C:\Users\Matthew\eee\eee.controls.exe.2\app/mondrian.ico (ArgumentError)
> 
> It’s really strange because ‘mondrian.ico’ is in the same folder as  
> ‘Controls.rb’ so I’d expect it to be found.  
> You’ve put it in the ‘bin’ dir of the package, but controls.rb is in the  
> ‘app’ dir. controls.rb loads the icon file like this:

Icon.new( File.join( File.dirname( **FILE** ), “mondrian.ico”),  
Wx::BITMAP\_TYPE\_ICO )

i.e. relative to its position. So it looks in the app dir, doesn’t find  
it and gives the error you saw. You’ll either need to put the icon file  
somewhere different in the bundle, or change that code.

You might find it helpful to unpack the bundle rubyscript2exe creates to  
see the directory structure. See the page for more details, but  
basically run it with the argument —eee-justextract

alex

---

<div class="post-metadata">

**Author:** ![Matthew\_Webb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/65b543/32.png) [@Matthew\_Webb](https://www.ruby-forum.com/u/Matthew_Webb)\
**Post date:** [March 28, 2008, 3:53pm UTC](https://www.ruby-forum.com/t/wxruby-rubyscript2exe/133112/5 "2008-03-28T15:53:25Z")

</div>

Alex F. wrote:

> > When I run the .exe I get this error…  
> > Icon.new( File.join( File.dirname( **FILE** ), “mondrian.ico”),  
> > alex
> 
> * * *
> 
> wxruby-users mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [http://rubyforge.org/mailman/listinfo/wxruby-users](http://rubyforge.org/mailman/listinfo/wxruby-users)

Okay I’ve finally managed to fix the problem I was having.

I found the following thread regarding rubyscript2exe & image loading…

> **[objectmix.com](http://objectmix.com/ruby/303278-re-rubyscript2exe-cannot-put-picture-project.html)**
>
> Find information, resources and relevant links for objectmix.com. This domain may be for sale.

If I rename the controls.rb file to init.rb & then “compile” the entire  
controls Directory like…

C:\Users\Matthew\Desktop\>rubyscript2exe controls/

it works fine.
