|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
swig ruby exampleHi.
I have a simple example and it doesnt work: First I removed first three lines in c:\ruby\lib\ruby\1.8\i386-mswin32\config.h Then I made following three files: example.c: int add(int a, int b) { return a+b; } example.i: %module example %{ extern int add(int a, int b); %} extern int add(int a, int b); extconf.rb: require 'mkmf' create_makefile("example")I After that I run Visual Studio 2008 command prompt: swig -ruby example.i ruby extconf.rb nmake mt.exe -manifest example.so.manifest -outputresource:example.so nmake install Then I run 'irb' and write 'require 'example'' When I hit enter I get a dialog complaining about 'msvcr90.dll' not found. I downloaded that file but then I get a dialog with some other errors. What am I doing wrong here ? Thanks Haris |
|
|
Re: swig ruby exampleharis_b wrote:
> Hi. > > I have a simple example and it doesnt work: > > First I removed first three lines in > c:\ruby\lib\ruby\1.8\i386-mswin32\config.h > > Then I made following three files: > > example.c: > > int add(int a, int b) > { > return a+b; > } > > example.i: > > %module example > %{ > extern int add(int a, int b); > %} > extern int add(int a, int b); > > extconf.rb: > > require 'mkmf' > create_makefile("example")I > After that I run Visual Studio 2008 command prompt: > > swig -ruby example.i > ruby extconf.rb > nmake > mt.exe -manifest example.so.manifest -outputresource:example.so > nmake install > > Then I run 'irb' and write 'require 'example'' > When I hit enter I get a dialog complaining about 'msvcr90.dll' not found. > I downloaded that file but then I get a dialog with some other errors. > > What am I doing wrong here ? > > Thanks > Haris > > I noticed in you extconf.rb: you have an 'I' at the end > create_makefile("example")I it should just be >create_makefile("example") In your example.i file, you can remove the extern linkage from the function prototypes (forward declaration). You only need to add this for variable that are defined in another file, so my example.i looks like this: %module example int add(int a, int b); also get into the habit of creating a header file for you function prototype, and then include it from you .c or .cpp file /* file example.h */ int add(int a, int b); /* file: example.c */ #include "example.h" int add(int a, int b) { return a+b; } On my Linux box, I am able to build and get the following example code working. As for the msvcr90.dll error, it seems you're missing some runtime dlls, this might help: http://support.microsoft.com/kb/326922 As far as you swig code goes with the minor, it looks good to go! -- Kind Regards, Rajinder Yadav http://DevMentor.org Do Good ~ Share Freely ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Swig-user mailing list Swig-user@... https://lists.sourceforge.net/lists/listinfo/swig-user |
| Free embeddable forum powered by Nabble | Forum Help |