Hello,
I am looking for an example/tutorial on extending ruby with C using
windows.
I add the using windows because I was to extend pcap ruby to windows
(one
day), and it is what i currently have installed. I read the pickaxe book
and
the example does not work for me. I think my problem with pickaxe
example is
the location of my file in the ruby dir. I was getting and error with
the
value statment so i removed all the code excpet the return self in the
functions. and i get
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in require__': C:\ruby\lib\ruby\Test.rb:7: void value expression (SyntaxError) return self; ^ C:\ruby\lib\ruby\Test.rb:7: odd number list for Hash return self; ^ C:\ruby\lib\ruby\Test.rb:7: syntax error return self; ^ C:\ruby\lib\ruby\Test.rb:8: syntax error from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in require’
from testtest.rb:1
I read this Radar – O’Reilly and
it is
in linux, make does not work.
Hello,
I am looking for an example/tutorial on extending ruby with C using
windows.
I add the using windows because I was to extend pcap ruby to windows
(one
day), and it is what i currently have installed. I read the pickaxe book
and
the example does not work for me. I think my problem with pickaxe
example is
the location of my file in the ruby dir. I was getting and error with
the
value statment so i removed all the code excpet the return self in the
functions. and i get
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in require__': C:\ruby\lib\ruby\Test.rb:7: void value expression (SyntaxError) return self; ^ C:\ruby\lib\ruby\Test.rb:7: odd number list for Hash return self; ^ C:\ruby\lib\ruby\Test.rb:7: syntax error return self; ^ C:\ruby\lib\ruby\Test.rb:8: syntax error from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in require’
from testtest.rb:1
Is return self; in the C code? (The C level does not have an
implicit self.) Does everything compile OK with extconf.rb?
If you post the code, we can troubleshoot.
I read this Radar – O’Reilly and
it is
in linux, make does not work.
error
[error]
C:\ruby\Test.rb:2: warning: parenthesize argument(s) for future version
C:\ruby\Test.rb:2: warning: parenthesize argument(s) for future version
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in require__': C:\ruby\Test.rb:4: syntax error (SyntaxError) VALUE arr; ^ C:\ruby\Test.rb:8: syntax error from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:inrequire’
from testtest.rb:1
[error]
I am using the pickaxe example to help learn how it is writen.
Thank you once again.
Becker
my run program
[code]
require “C:\ruby\Test”
t = Test.new()
t.add(“Bill Chase”)
[code]
my code example from pickaxe saved as a .rb
This here is the problem; the below code must be
saved as a .c file and then compiled to a library
using extconf.rb (the Pickaxe should have further
instructions for this). Once done, you will have
a Test.so file that you can #require for example
from irb.
[code] #include “ruby.h”
static VALUE t_init(VALUE self)
{
VALUE arr;
arr = rb_ary_new();
rb_iv_set(self, “@arr”, arr);
return self;
}
static VALUE t_add(VALUE self, VALUE anObject)
{
VALUE arr;
arr = rb_iv_get(self, “@arr”);
rb_ary_push(arr, anObject);
return arr;
}
Microsoft (R) Program Maintenance Utility Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.
cl -nologo -MD -Zi -O2b2xg- -G6 -I.
-Ic:/ruby/lib/ruby/1.8/i386-mswin32
-Ic:/ruby/lib/ruby/1.8/i386-mswin32 -IC:/ruby/code -I. -I./…
-I./…/missing -c
-TcTest.c
‘cl’ is not recognized as an internal or external command,
operable program or batch file.
NMAKE : fatal error U1077: ‘C:\WINDOWS\system32\cmd.exe’ : return code
‘0x1’
Stop.
but it only created the makefile which in windows make is not a command.
What do i do with the file instead?
Windows can use a program called ‘nmake’ that you can use.
In addition to this, you would need to install a C compiler.
Microsoft does offer a free version of theirs. Both should
be available somewhere on http://www.msdn.com.
Alternatively, you could install the MinGW toolkit from http://www.mingw.org, it provides minimal GNU tools.
Copyright (c) Microsoft Corp 1988-94. All rights reserved.
cl -nologo -MD -Zi -O2b2xg- -G6 -I.
-Ic:/ruby/lib/ruby/1.8/i386-mswin32
-Ic:/ruby/lib/ruby/1.8/i386-mswin32 -IC:/ruby/code -I. -I./…
-I./…/missing -c
-TcTest.c
Test.c
c:\ruby\lib\ruby\1.8\i386-mswin32\win32\win32.h(25) : fatal error C1083:
Cannot
open include file: ‘windows.h’: No such file or directory
You need to tell the compiler about the directory that includes the
header file windows.h. You can probably do this via giving the
compiler line the following: -I/, where is the directory
that contains windows.h.
Did that, I got an error for the dir having a space in the ie :
f:\documents
and settings, so i copied the code folder to my c drive root ( c:\rcode)
and now i get the error