Hi folks, had a question regarding C11/C++11 and ruby interoperability.

Assuming we have a very well written, concurrent, network client library in
C/C++11 I'd like to hear your thoughts on reusing that in ruby say as a
gem. More specifically, say with in RoR.

I'm leaving this vague to welcome thoughts, lessons, best practices from
folks who have attempted or know enough about these topics to comment on.



Arvind Kalyan
cell: (408) 761-2030

Hi Arvind,

it’s been some time since I last bridged a C++ library to Ruby (or even
a C library), but it is possible. The important thing to ensure is that
the extension’s Init_*() function is declared as C linkage (“extern
"C"”) so that Ruby’s C extension mechanism finds it. Other than that,
bridging a C++ library to Ruby is not that different from a pure C
library. For an example of how to bridge a C++ library to Ruby, have a
look at this (unfinished) port of wxWidgets 3 to Ruby:


The version of C++ shouldn’t matter, so if you need C++11, ensure you
specify the proper compiler switches when building your library.

Using a library in Rails is no different than using a library in regular
Ruby. Just please don’t make Rails a dependency of your library so that
non-rails users can enjoy it as well.



Blog: http://www.quintilianus.eu

I will reject HTML emails. | Ich akzeptiere keine HTML-Nachrichten.
Use GnuPG for mail encryption: | GnuPG für Mail-Verschlüsselung:
https://www.gnupg.org | https://de.wikipedia.org/wiki/GnuPG
My key fingerprint: | Mein Schlüsselabdruck:
B1FE 958E D5E8 468E AA20 | B1FE 958E D5E8 468E AA20
8F4B F1D8 799F BCC8 BC4F | 8F4B F1D8 799F BCC8 BC4F