[ANN] rb++ / rbgccxml 0.9.1

What is rb++ / rbgccxml?

  Rb++, rbgccxml, and rice compose a suite of tools that make wrapping C++
libraries into
  Ruby extensions as simple as possible. This is built as a replacement for
SWIG-Ruby.

What's New

  * Full 1.9 support through the entire stack!
  * MinGW / MSYS build support on Windows.

  rb++:
    * Updated to work with the Rice::Director changes
    * Fixed a bug where rb++ wasn't using any superclass on classes with
multiple superclasses
    * Generated extension handles exceptions cleaner

    * Various other small bug fixes and tweaks

  rbgccxml:
    * Switched parsing from libxml-ruby to nokogiri
    * Fixed crash on encountering <Union>, but no real handling of the type
yet.
    * Fixed a bug with older gcc versions on dealing with anonymous
enumerations

Project

  Documentation: http://rbplusplus.rubyforge.org

  rb++: http://github.com/jameskilton/rbplusplus
  rbgccxml: http://github.com/jameskilton/rbgccxml

Installation

  This single command will grab the whole stack needed for rb++ to work.

    gem install rbplusplus

  The stack includes four libraries: rb++, rbgccxml, gccxml_gem, and rice

rb++

  Rb++ makes it almost trivially easy to create Ruby extensions for C++
library.
  In the simplest of cases, there is no need to ever touch C++, everything
is done
  in a very simple and clean Ruby API.

rbgccxml

  RbGCCXML allows one to easily parse out and query C / C++ code.
  This library uses GCC-XML to parse out the C / C++ code into XML, and then
nokogiri
  to parse and query that XML.

gccxml_gem

  GCC-XML (www.gccxml.org) is an application that takes takes the parse tree
of C / C++
  and constructs a very parsable and queryable XML file with all related
information.

  This gem includes a binary build of GCC-XML for supported platforms,
  to make it trivially easy to install. Platforms currently supported are:

    * Linux 32 & 64 bit
    * Mac OS X
    * Windows via MinGW / MSYS

Rice

  The Ruby Interface for C++ Extensions, it provides a C++ API for working
with ruby. More information
  available at its project page:

    http://rice.rubyforge.org

Notes

  Released under the MIT licence.

  For those familiar with py++ / pygccxml, the similarities are in function
only.
  Rb++ / rbgccxml were written from scratch to take advantage of the Ruby
language to it's fullest.

  Bugs, patches, feature requests, et al should be posted to the
corresponding project's Issues page on github.

Hi,

I seem to have something like a bug in rb++. For the case that I want to
wrap a simple method
the extension doesn't compile because of multiple definitions. The issue
is somewhat tricky since
when I have a previously compiled extension and merely extend the header
file, it compiles fine.
Here test case:

wrapper.rb
require 'rubygems'
require 'rbplusplus'

include RbPlusPlus

Extension.new "test" do |ext|
  ext.sources ["/home/thor/rb++/test.hpp"]

  ext.module "Test" do |mod|
    node = mod.namespace "T"
  end
end

test.hpp
#ifndef TEST
#define TEST

#include <iostream>

namespace T
{

  void test()
  {
    std::cout << "i'm just sitting here" << std::endl;
  }

}
#endif

The error is encountered also if I have a class before the function test.

Thorsten

Jason Roelofs wrote:

···

What is rb++ / rbgccxml?

  Rb++, rbgccxml, and rice compose a suite of tools that make wrapping C++
libraries into
  Ruby extensions as simple as possible. This is built as a replacement for
SWIG-Ruby.

What's New

  * Full 1.9 support through the entire stack!
  * MinGW / MSYS build support on Windows.

  rb++:
    * Updated to work with the Rice::Director changes
    * Fixed a bug where rb++ wasn't using any superclass on classes with
multiple superclasses
    * Generated extension handles exceptions cleaner

    * Various other small bug fixes and tweaks

  rbgccxml:
    * Switched parsing from libxml-ruby to nokogiri
    * Fixed crash on encountering <Union>, but no real handling of the type
yet.
    * Fixed a bug with older gcc versions on dealing with anonymous
enumerations

Project

  Documentation: http://rbplusplus.rubyforge.org

  rb++: GitHub - jameskilton/rbplusplus: Account name changed!
  rbgccxml: GitHub - jameskilton/rbgccxml: Account name changed!

Installation

  This single command will grab the whole stack needed for rb++ to work.

    gem install rbplusplus

  The stack includes four libraries: rb++, rbgccxml, gccxml_gem, and rice

rb++

  Rb++ makes it almost trivially easy to create Ruby extensions for C++
library.
  In the simplest of cases, there is no need to ever touch C++, everything
is done
  in a very simple and clean Ruby API.

rbgccxml

  RbGCCXML allows one to easily parse out and query C / C++ code.
  This library uses GCC-XML to parse out the C / C++ code into XML, and then
nokogiri
  to parse and query that XML.

gccxml_gem

  GCC-XML (www.gccxml.org) is an application that takes takes the parse tree
of C / C++
  and constructs a very parsable and queryable XML file with all related
information.

  This gem includes a binary build of GCC-XML for supported platforms,
  to make it trivially easy to install. Platforms currently supported are:

    * Linux 32 & 64 bit
    * Mac OS X
    * Windows via MinGW / MSYS

Rice

  The Ruby Interface for C++ Extensions, it provides a C++ API for working
with ruby. More information
  available at its project page:

    http://rice.rubyforge.org

Notes

  Released under the MIT licence.

  For those familiar with py++ / pygccxml, the similarities are in function
only.
  Rb++ / rbgccxml were written from scratch to take advantage of the Ruby
language to it's fullest.

  Bugs, patches, feature requests, et al should be posted to the
corresponding project's Issues page on github.

What you're running into is a general C++ compilation issue when you have
code in your header files. By default, rb++ writes out code in a
one-file-per-class format, along with another file that's the ruby extension
starting point. Your test.hpp file ends up getting included into multiple
files, and g++ doesn't like it when it sees a fully defined method multiple
times.

Two ways to deal with this:

1) Tell rb++ to write all code to single file:

  ext.writer_mode :single

2) Split your C++ code out:

test.hpp
  namespace T { void test(); }

test.cpp
  namespace T { void test() { ... } }

Jason

···

On Fri, Dec 18, 2009 at 9:02 AM, Thorsten Hater <th@tp1.rub.de> wrote:

Hi,

I seem to have something like a bug in rb++. For the case that I want to
wrap a simple method
the extension doesn't compile because of multiple definitions. The issue
is somewhat tricky since
when I have a previously compiled extension and merely extend the header
file, it compiles fine.
Here test case:

wrapper.rb
require 'rubygems'
require 'rbplusplus'

include RbPlusPlus

Extension.new "test" do |ext|
ext.sources ["/home/thor/rb++/test.hpp"]

ext.module "Test" do |mod|
   node = mod.namespace "T"
end
end

test.hpp
#ifndef TEST
#define TEST

#include <iostream>

namespace T
{

void test()
{
   std::cout << "i'm just sitting here" << std::endl;
}

}
#endif

The error is encountered also if I have a class before the function test.

Thorsten

Jason Roelofs wrote:
> What is rb++ / rbgccxml?
>
> Rb++, rbgccxml, and rice compose a suite of tools that make wrapping
C++
> libraries into
> Ruby extensions as simple as possible. This is built as a replacement
for
> SWIG-Ruby.
>
> What's New
>
> * Full 1.9 support through the entire stack!
> * MinGW / MSYS build support on Windows.
>
> rb++:
> * Updated to work with the Rice::Director changes
> * Fixed a bug where rb++ wasn't using any superclass on classes with
> multiple superclasses
> * Generated extension handles exceptions cleaner
>
> * Various other small bug fixes and tweaks
>
>
> rbgccxml:
> * Switched parsing from libxml-ruby to nokogiri
> * Fixed crash on encountering <Union>, but no real handling of the
type
> yet.
> * Fixed a bug with older gcc versions on dealing with anonymous
> enumerations
>
>
> Project
>
> Documentation: http://rbplusplus.rubyforge.org
>
> rb++: GitHub - jameskilton/rbplusplus: Account name changed!
> rbgccxml: GitHub - jameskilton/rbgccxml: Account name changed!
>
>
> Installation
>
> This single command will grab the whole stack needed for rb++ to work.
>
> gem install rbplusplus
>
> The stack includes four libraries: rb++, rbgccxml, gccxml_gem, and rice
>
>
> rb++
>
> Rb++ makes it almost trivially easy to create Ruby extensions for C++
> library.
> In the simplest of cases, there is no need to ever touch C++,
everything
> is done
> in a very simple and clean Ruby API.
>
>
>
> rbgccxml
>
> RbGCCXML allows one to easily parse out and query C / C++ code.
> This library uses GCC-XML to parse out the C / C++ code into XML, and
then
> nokogiri
> to parse and query that XML.
>
>
>
> gccxml_gem
>
> GCC-XML (www.gccxml.org) is an application that takes takes the parse
tree
> of C / C++
> and constructs a very parsable and queryable XML file with all related
> information.
>
> This gem includes a binary build of GCC-XML for supported platforms,
> to make it trivially easy to install. Platforms currently supported
are:
>
> * Linux 32 & 64 bit
> * Mac OS X
> * Windows via MinGW / MSYS
>
>
> Rice
>
> The Ruby Interface for C++ Extensions, it provides a C++ API for
working
> with ruby. More information
> available at its project page:
>
> http://rice.rubyforge.org
>
>
> Notes
>
> Released under the MIT licence.
>
> For those familiar with py++ / pygccxml, the similarities are in
function
> only.
> Rb++ / rbgccxml were written from scratch to take advantage of the Ruby
> language to it's fullest.
>
> Bugs, patches, feature requests, et al should be posted to the
> corresponding project's Issues page on github.
>
>

Well, actually it shouldn't be included more than one time due
to the header guard.
But, you're correct having method definitions in headers is not
good style, so I decided to go the second route. Now ruby claims
that the symbol test is undefined.
Depending on the sources array, I get:
hpp --> undefined symbol
hpp + cpp --> double definition
           cpp --> double definition
I am doing something really stupid here, or is there a way to rb++
to treat hpp + cpp as a package?

Thorsten

Jason Roelofs wrote:

···

What you're running into is a general C++ compilation issue when you have
code in your header files. By default, rb++ writes out code in a
one-file-per-class format, along with another file that's the ruby extension
starting point. Your test.hpp file ends up getting included into multiple
files, and g++ doesn't like it when it sees a fully defined method multiple
times.

Two ways to deal with this:

1) Tell rb++ to write all code to single file:

  ext.writer_mode :single

2) Split your C++ code out:

test.hpp
  namespace T { void test(); }

test.cpp
  namespace T { void test() { ... } }

Jason

On Fri, Dec 18, 2009 at 9:02 AM, Thorsten Hater <th@tp1.rub.de> wrote:

Hi,

I seem to have something like a bug in rb++. For the case that I want to
wrap a simple method
the extension doesn't compile because of multiple definitions. The issue
is somewhat tricky since
when I have a previously compiled extension and merely extend the header
file, it compiles fine.
Here test case:

wrapper.rb
require 'rubygems'
require 'rbplusplus'

include RbPlusPlus

Extension.new "test" do |ext|
ext.sources ["/home/thor/rb++/test.hpp"]

ext.module "Test" do |mod|
   node = mod.namespace "T"
end
end

test.hpp
#ifndef TEST
#define TEST

#include <iostream>

namespace T
{

void test()
{
   std::cout << "i'm just sitting here" << std::endl;
}

}
#endif

The error is encountered also if I have a class before the function test.

Thorsten

Jason Roelofs wrote:
    

What is rb++ / rbgccxml?

  Rb++, rbgccxml, and rice compose a suite of tools that make wrapping
      

C++
    

libraries into
  Ruby extensions as simple as possible. This is built as a replacement
      

for
    

SWIG-Ruby.

What's New

  * Full 1.9 support through the entire stack!
  * MinGW / MSYS build support on Windows.

  rb++:
    * Updated to work with the Rice::Director changes
    * Fixed a bug where rb++ wasn't using any superclass on classes with
multiple superclasses
    * Generated extension handles exceptions cleaner

    * Various other small bug fixes and tweaks

  rbgccxml:
    * Switched parsing from libxml-ruby to nokogiri
    * Fixed crash on encountering <Union>, but no real handling of the
      

type
    

yet.
    * Fixed a bug with older gcc versions on dealing with anonymous
enumerations

Project

  Documentation: http://rbplusplus.rubyforge.org

  rb++: GitHub - jameskilton/rbplusplus: Account name changed!
  rbgccxml: GitHub - jameskilton/rbgccxml: Account name changed!

Installation

  This single command will grab the whole stack needed for rb++ to work.

    gem install rbplusplus

  The stack includes four libraries: rb++, rbgccxml, gccxml_gem, and rice

rb++

  Rb++ makes it almost trivially easy to create Ruby extensions for C++
library.
  In the simplest of cases, there is no need to ever touch C++,
      

everything
    

is done
  in a very simple and clean Ruby API.

rbgccxml

  RbGCCXML allows one to easily parse out and query C / C++ code.
  This library uses GCC-XML to parse out the C / C++ code into XML, and
      

then
    

nokogiri
  to parse and query that XML.

gccxml_gem

  GCC-XML (www.gccxml.org) is an application that takes takes the parse
      

tree
    

of C / C++
  and constructs a very parsable and queryable XML file with all related
information.

  This gem includes a binary build of GCC-XML for supported platforms,
  to make it trivially easy to install. Platforms currently supported
      

are:
    

    * Linux 32 & 64 bit
    * Mac OS X
    * Windows via MinGW / MSYS

Rice

  The Ruby Interface for C++ Extensions, it provides a C++ API for
      

working
    

with ruby. More information
  available at its project page:

    http://rice.rubyforge.org

Notes

  Released under the MIT licence.

  For those familiar with py++ / pygccxml, the similarities are in
      

function
    

only.
  Rb++ / rbgccxml were written from scratch to take advantage of the Ruby
language to it's fullest.

  Bugs, patches, feature requests, et al should be posted to the
corresponding project's Issues page on github.

Sorry, I should have pointed you further towards the right answer. What you
want is to have hpp + cpp (prototype in the hpp, implementation in the cpp)
then you need to tell Rb++ to copy over the cpp file in with the generated
sources so that it's properly compiled and the linker can find the
implementation of code defined in the hpp:

Extension.new "test" do |e|
  e.sources "test.hpp", :include_source_files => "test.cpp"
end

A more detailed example and definition is found in the tutorial:
http://rbplusplus.rubyforge.org/#source\. Also please read the documentation
on Extension#sources:
http://rbplusplus.rubyforge.org/rbplusplus/classes/RbPlusPlus/Extension.html#M000092

Jason

···

On Tue, Dec 22, 2009 at 8:19 AM, Thorsten Hater <th@tp1.rub.de> wrote:

Well, actually it shouldn't be included more than one time due
to the header guard.
But, you're correct having method definitions in headers is not
good style, so I decided to go the second route. Now ruby claims
that the symbol test is undefined.
Depending on the sources array, I get:
hpp --> undefined symbol
hpp + cpp --> double definition
          cpp --> double definition
I am doing something really stupid here, or is there a way to rb++
to treat hpp + cpp as a package?

Thorsten

Jason Roelofs wrote:
> What you're running into is a general C++ compilation issue when you have
> code in your header files. By default, rb++ writes out code in a
> one-file-per-class format, along with another file that's the ruby
extension
> starting point. Your test.hpp file ends up getting included into multiple
> files, and g++ doesn't like it when it sees a fully defined method
multiple
> times.
>
> Two ways to deal with this:
>
> 1) Tell rb++ to write all code to single file:
>
> ext.writer_mode :single
>
> 2) Split your C++ code out:
>
> test.hpp
> namespace T { void test(); }
>
> test.cpp
> namespace T { void test() { ... } }
>
> Jason
>
> On Fri, Dec 18, 2009 at 9:02 AM, Thorsten Hater <th@tp1.rub.de> wrote:
>
>
>> Hi,
>>
>> I seem to have something like a bug in rb++. For the case that I want to
>> wrap a simple method
>> the extension doesn't compile because of multiple definitions. The issue
>> is somewhat tricky since
>> when I have a previously compiled extension and merely extend the header
>> file, it compiles fine.
>> Here test case:
>>
>> wrapper.rb
>> require 'rubygems'
>> require 'rbplusplus'
>>
>> include RbPlusPlus
>>
>> Extension.new "test" do |ext|
>> ext.sources ["/home/thor/rb++/test.hpp"]
>>
>> ext.module "Test" do |mod|
>> node = mod.namespace "T"
>> end
>> end
>>
>> test.hpp
>> #ifndef TEST
>> #define TEST
>>
>> #include <iostream>
>>
>> namespace T
>> {
>>
>> void test()
>> {
>> std::cout << "i'm just sitting here" << std::endl;
>> }
>>
>> }
>> #endif
>>
>> The error is encountered also if I have a class before the function
test.
>>
>> Thorsten
>>
>>
>> Jason Roelofs wrote:
>>
>>> What is rb++ / rbgccxml?
>>>
>>> Rb++, rbgccxml, and rice compose a suite of tools that make wrapping
>>>
>> C++
>>
>>> libraries into
>>> Ruby extensions as simple as possible. This is built as a replacement
>>>
>> for
>>
>>> SWIG-Ruby.
>>>
>>> What's New
>>>
>>> * Full 1.9 support through the entire stack!
>>> * MinGW / MSYS build support on Windows.
>>>
>>> rb++:
>>> * Updated to work with the Rice::Director changes
>>> * Fixed a bug where rb++ wasn't using any superclass on classes
with
>>> multiple superclasses
>>> * Generated extension handles exceptions cleaner
>>>
>>> * Various other small bug fixes and tweaks
>>>
>>>
>>> rbgccxml:
>>> * Switched parsing from libxml-ruby to nokogiri
>>> * Fixed crash on encountering <Union>, but no real handling of the
>>>
>> type
>>
>>> yet.
>>> * Fixed a bug with older gcc versions on dealing with anonymous
>>> enumerations
>>>
>>>
>>> Project
>>>
>>> Documentation: http://rbplusplus.rubyforge.org
>>>
>>> rb++: GitHub - jameskilton/rbplusplus: Account name changed!
>>> rbgccxml: GitHub - jameskilton/rbgccxml: Account name changed!
>>>
>>>
>>> Installation
>>>
>>> This single command will grab the whole stack needed for rb++ to
work.
>>>
>>> gem install rbplusplus
>>>
>>> The stack includes four libraries: rb++, rbgccxml, gccxml_gem, and
rice
>>>
>>>
>>> rb++
>>>
>>> Rb++ makes it almost trivially easy to create Ruby extensions for C++
>>> library.
>>> In the simplest of cases, there is no need to ever touch C++,
>>>
>> everything
>>
>>> is done
>>> in a very simple and clean Ruby API.
>>>
>>>
>>>
>>> rbgccxml
>>>
>>> RbGCCXML allows one to easily parse out and query C / C++ code.
>>> This library uses GCC-XML to parse out the C / C++ code into XML, and
>>>
>> then
>>
>>> nokogiri
>>> to parse and query that XML.
>>>
>>>
>>>
>>> gccxml_gem
>>>
>>> GCC-XML (www.gccxml.org) is an application that takes takes the
parse
>>>
>> tree
>>
>>> of C / C++
>>> and constructs a very parsable and queryable XML file with all
related
>>> information.
>>>
>>> This gem includes a binary build of GCC-XML for supported platforms,
>>> to make it trivially easy to install. Platforms currently supported
>>>
>> are:
>>
>>> * Linux 32 & 64 bit
>>> * Mac OS X
>>> * Windows via MinGW / MSYS
>>>
>>>
>>> Rice
>>>
>>> The Ruby Interface for C++ Extensions, it provides a C++ API for
>>>
>> working
>>
>>> with ruby. More information
>>> available at its project page:
>>>
>>> http://rice.rubyforge.org
>>>
>>>
>>> Notes
>>>
>>> Released under the MIT licence.
>>>
>>> For those familiar with py++ / pygccxml, the similarities are in
>>>
>> function
>>
>>> only.
>>> Rb++ / rbgccxml were written from scratch to take advantage of the
Ruby
>>> language to it's fullest.
>>>
>>> Bugs, patches, feature requests, et al should be posted to the
>>> corresponding project's Issues page on github.
>>>
>>>
>>>
>>
>>
>
>