S
Slava Shynkarenko
Dear community,
I would appreciate if you could help me to solve this. I’m experimenting
with Ruby 1.8.7 embedding. Ruby has been built from sources under
Windows by VisualStudio 2008 compiler, with no errors.
Here is my C++ code:
void main()
{
__try
{
RUBY_INIT_STACK;
ruby_init();
ruby_init_loadpath();
ruby_incpush( "C:/ruby1.8.7/lib/ruby/site_ruby/1.8" );
ruby_incpush(
"C:/ruby1.8.7/lib/ruby/site_ruby/1.8/i386-msvcr90" );
ruby_incpush( "C:/ruby1.8.7/lib/ruby/site_ruby" );
ruby_incpush( "C:/ruby1.8.7/lib/ruby/vendor_ruby/1.8" );
ruby_incpush(
"C:/ruby1.8.7/lib/ruby/vendor_ruby/1.8/i386-msvcr90" );
ruby_incpush( "C:/ruby1.8.7/lib/ruby/vendor_ruby" );
ruby_incpush( "C:/ruby1.8.7/lib/ruby/1.8" );
ruby_incpush(
"C:/ruby1.8.7/lib/ruby/1.8/i386-mswin32_90" );
ruby_script( "embedded" );
rb_load_file( "test.rb" );
ruby_run();
}
__finally
{
ruby_finalize();
}
}
Please note, it’s only an experiment, so please don’t pay much attention
on irrelevant mistakes.
This is my test.rb:
print "\n=== RUBY ===\n"
print "Hello World!"*3;
print "\n\nLoad:\n"
print $LOAD_PATH
print "\n"
require '1'
m = My.new
m.hello
print "\n=== GETTING LOCALHOST... ===\n"
require 'socket'
host = 'localhost'
port = 80
path = "/"
request = "GET #{path} HTTP/1.0\r\n\r\n"
socket = TCPSocket.open( host, port )
socket.print( request )
response = socket.read
headers, body = response.split( "\r\n\r\n", 2 )
print body
And that is 1.rb, which is located near test.rb:
class My
def hello
print "Hello from class My";
end
end
The socket code actually produces segmentation fault. More precisely
it’s the “require†statement. So everything works well except the socket
part. And by commenting out all the socket-relevant code, I’ve learned
that exactly the “require†statement causes the issue.
Note, everything works great when I run the script by ruby.exe, compiled
myself!
Please help me to proceed.
Thank you.
I would appreciate if you could help me to solve this. I’m experimenting
with Ruby 1.8.7 embedding. Ruby has been built from sources under
Windows by VisualStudio 2008 compiler, with no errors.
Here is my C++ code:
void main()
{
__try
{
RUBY_INIT_STACK;
ruby_init();
ruby_init_loadpath();
ruby_incpush( "C:/ruby1.8.7/lib/ruby/site_ruby/1.8" );
ruby_incpush(
"C:/ruby1.8.7/lib/ruby/site_ruby/1.8/i386-msvcr90" );
ruby_incpush( "C:/ruby1.8.7/lib/ruby/site_ruby" );
ruby_incpush( "C:/ruby1.8.7/lib/ruby/vendor_ruby/1.8" );
ruby_incpush(
"C:/ruby1.8.7/lib/ruby/vendor_ruby/1.8/i386-msvcr90" );
ruby_incpush( "C:/ruby1.8.7/lib/ruby/vendor_ruby" );
ruby_incpush( "C:/ruby1.8.7/lib/ruby/1.8" );
ruby_incpush(
"C:/ruby1.8.7/lib/ruby/1.8/i386-mswin32_90" );
ruby_script( "embedded" );
rb_load_file( "test.rb" );
ruby_run();
}
__finally
{
ruby_finalize();
}
}
Please note, it’s only an experiment, so please don’t pay much attention
on irrelevant mistakes.
This is my test.rb:
print "\n=== RUBY ===\n"
print "Hello World!"*3;
print "\n\nLoad:\n"
print $LOAD_PATH
print "\n"
require '1'
m = My.new
m.hello
print "\n=== GETTING LOCALHOST... ===\n"
require 'socket'
host = 'localhost'
port = 80
path = "/"
request = "GET #{path} HTTP/1.0\r\n\r\n"
socket = TCPSocket.open( host, port )
socket.print( request )
response = socket.read
headers, body = response.split( "\r\n\r\n", 2 )
print body
And that is 1.rb, which is located near test.rb:
class My
def hello
print "Hello from class My";
end
end
The socket code actually produces segmentation fault. More precisely
it’s the “require†statement. So everything works well except the socket
part. And by commenting out all the socket-relevant code, I’ve learned
that exactly the “require†statement causes the issue.
Note, everything works great when I run the script by ruby.exe, compiled
myself!
Please help me to proceed.
Thank you.