From: Brian Candler Date: 2002-11-16T09:53:15+09:00 Subject: Re: Exerb for Linux ? --X1bOJ3K7DJ5YkBrT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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++ ! 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 :-) 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 :-) --X1bOJ3K7DJ5YkBrT Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="exerb.c" /* * Compile this using something like the following: * gcc -Wall -o myprog -static exerb.c -lruby -lm -lcrypt \ * -L/usr/local/lib/ruby/1.6/i386-freebsd4.6 \ * -I/usr/local/lib/ruby/1.6/i386-freebsd4.6 * See: http://www.rubycentral.com/book/ext_ruby.html * and main.c from the ruby distribution */ static char *prog=" puts \"hello, world!\\n\"; puts \"the end\\n\"; "; #include "ruby.h" int main(int argc, char *argv[]) { ruby_init(); /* ruby_options(argc, argv); waits until EOF on stdin? */ ruby_script("exerb"); rb_eval_string(prog); return 0; } --X1bOJ3K7DJ5YkBrT--