Exerb for Linux?

Hi,

does somebody already developed an equivalent of windoze’s Exerb project on
Linux ?
I am in bad need of such a wrapper to make a single executable file for a Ruby
project, using MySQL and Ruby-Gnome, preferably statically linked… and I
don’t want to recode everything in C++ !

Thanks,

Francois

Err, well you could always do something like the attached.

I don't see a good reason for doing this on a Unix system though. It doesn't
make your source code any safer (you could add scrambling but it would be
trivial to bypass); it won't be any quicker to start than
#!/usr/local/bin/ruby; and you end up with a 1.6MB binary for Hello World.

I suppose it makes it slightly harder for people to tamper with your
scripts, but IMO using file permissions is simpler and more effective :slight_smile:

Regards,

Brian.

P.S. I have a feeling that something is not being initialised correctly,
because calling ruby_options makes the script halt at that point until it
gets an EOF on stdin - so use this at your own risk and/or do some research
to find out what the problem is :slight_smile:

exerb.c (580 Bytes)

···

On Fri, Nov 15, 2002 at 12:49:52PM +0900, Francois GORET wrote:

does somebody already developed an equivalent of windoze's Exerb project on
Linux ?
I am in bad need of such a wrapper to make a single executable file for a Ruby
project, using MySQL and Ruby-Gnome, preferably statically linked... and I
don't want to recode everything in C++ !

<hasty_retreat>
Of course that's no good if you 'require' any external libraries. So this
isn't actually as trivial as I thought it was.
</hasty_retreat>

I suppose there is a real project in there then, if anyone is sufficiently
interested in making such monolithic hybrid script/binaries.

Regards,

Brian.

P.S. please excuse the superfluous semicolons in the Ruby code. That's what
happens if you write in two languages at once :slight_smile:

Hi Brian,

Thanks a lot for your help which fits nicely on what I found in a sleepless
night:

  • have to make a static compile of Ruby, and of all the extentions in the ext/
    directory (after moving the extra stuff like mysql inside the ext/ )

  • say something like:
    gcc -g -O2 -static -L/usr/lib/mysql -L. -L/usr/X11R6/lib
    main.o ext/extinit.o ext/curses/curses.a ext/dbm/dbm.a \
    ext/digest/digest.a ext/digest/md5/md5.a ext/digest/rmd160/rmd160.a
    ext/digest/sha1/sha1.a ext/digest/sha2/sha2.a ext/dl/dl.a ext/etc/etc.a
    ext/fcntl/fcntl.a ext/gdbm/gdbm.a ext/iconv/iconv.a ext/nkf/nkf.a
    ext/pty/pty.a ext/racc/cparse/cparse.a ext/readline/readline.a
    ext/sdbm/sdbm.a ext/socket/socket.a ext/stringio/stringio.a
    ext/strscan/strscan.a ext/syslog/syslog.a
    ext/tcltklib/tcltklib.a ext/tk/tkutil.a ext/mysql/mysql.a
    -lruby -ldl -lcrypt -lm -lncurses -lgpm -ldb -lcrypto -ldl -lgdbm
    -lutil -lreadline -lncurses -ltk8.4 -ltcl8.4 -lX11 -lm
    -ldl -lz -lmysqlclient -lz -o appname

where main.o is the program you kindly provided me. Once stripped, a complete
one file ruby interpreter is about 3.8 Mb. Of course, I should get rid of
modules I don’t use like tcltk, X11, curses… A good idea would be to move
all the extention modules inside the libruby.a.

  • the next step is to make a little ruby program to make one big ruby source
    by assembling all the required .rb files from the library, and have the
    resulting big file formatted so that C can eat it as a string constant.

There a some problems left, for example I don’t see how to make DATA
work… Fortunately, nobody seems to use it in the libraries.

------------------------- Why bother ?

I’m doing a restaurant / pos program, to be installed on 40++ computers / cash
registers next year, using Gtk2 on Linux framebuffer (no X!). I’m waiting for
ruby-gnome2… The big statically linked binary is the easiest way I see to
install this application on low level machines: just take a basic, minimal
linux distro (like the ‘A’ disks of slackware), then make that static binary
the “login shell” of the user, and spend the rest of the afternoon on the
beach…

Thanks again for your help,

Francois