From: Martin Stannard Date: 2001-11-02T11:40:06+09:00 Subject: [ruby-talk:24137] Embedding ruby and net libraries Hi, I've managed to get Ruby embedded into a c++ program and would like to use some of the Net modules from within the app. I'm using rb_eval_string_protect to a string like so: int state = 0; char* mailme = "require 'net/smtp' \r\n \ msg = [ \"Subject: Test\n\", \"\n\", \"Test message\n\" ] \r\n \ Net::SMTP.start('xxx.xxx.xxxx') do |smtp| \r\n\ smtp.sendmail( msg, 'martin@massive.com.au', ['martin@massive.com.au'] ) \r\n\ end"; result = rb_eval_string_protect(mailme, &state); if (state) { result = rb_inspect(rb_gv_get("$!")); char* e = RSTRING(result)->ptr; } When run I get the following error message in e: # If I move the net dir from the ruby distribution into the directory I'm running from and change the require to require 'net/smtp.rb' then smtp.rb is found. However smtp.rb requires 'protocol' so I end up with the same exception, except this time: # Is there a way of overcoming this annoyance so that the networking libs can be used by and embedded interpreter? regards, Martin