Creating a Ruby C++ extension

View: New views
2 Messages — Rating Filter:   Alert me  

Creating a Ruby C++ extension

by Rajinder Yadav-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I am very new to SWIG, but wanted to know why I can't seem to get the following
code to build? I am sure I am doing something wrong. I created the 3 files below
to get something going.

 From the shell I am typing:

$> swig -g++ -ruby person.i
$> ruby extperson.rb
$> make

but I am getting a build errors.

#===================
# file: extperson.rb

require 'mkmf'
create_makefile('person')



//==================
// file: person.i

%module person

class Person
{
    char str[100];
public:
    Person();
    ~Person();

    char* greet();

};


//==================
// file: person.cpp

#include <cstdlib>
#include <cstring>

class Person
{
    char str[100];
public:
    Person();
    ~Person();

    char* greet();

};


Person::Person()
{
    strncpy( str, "Hello", 100 );
}
Person::~Person() {}

char* Person::greet()
{
    return str;
}


--
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

[SOLVED] Re: Creating a Ruby C++ extension

by Rajinder Yadav-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I was able to track down a very old (Jan 2000)  "Linux Gazette"
article that showed me how to build a Ruby module in C++ using SWIG.

Now on to understanding the bigger stuff about memory management and
garbage collection.

--
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