From: richard a. <ric...@ya...> - 2006-10-10 06:16:49
|
I'm trying to get Ruby scripting to work with Open Babel-2.0.2 and SWIG on Linux. So far I've been able to generate the openbabel_wrap.cxx file with SWIG from OB's openbabel.i file and the OB sources. The bottom of this file contains all of the Ruby module, class, and method definitions, as expected. I created an apparently correct extconf.rb file, which I then used to create a makefile. With a little tweaking (I needed to add #include <math.h> at the top of the .cxx file), I was able to compile openbabel_wrap.cxx against my installed OB-2.0.2 library using make. So far so good. With irb, however, loading the module segfaults: BUG] Segmentation fault ruby 1.8.5 (2006-08-25) [x86_64-linux-gnu] Aborted Not really that helpful. I was able to trace the problem to only three class definitions in obenbabel_wrap.cxx: OBAtom OBBond OBMol If I remove these three definitions, I can compile the module, load it through Ruby, and manipulate OB objects. In the case of OBAtom, the offending code is at the very start of the class stanza: cOBAtom.klass = rb_define_class_under(mRob, "OBAtom", ((swig_class *) SWIGTYPE_p_OpenBabel__OBNodeBase->clientdata)->klass); I suspect the same is true for OBBond and OBMol, but haven't checked. I initially thought that maybe this problem was linked to OBAtom inheriting from another OB object. But so does OBElementTable, for example, and that definition doesn't cause a segfault. Any ideas? I'm not very experienced with Ruby extensions, C, C++, or make, so any information would be helpful. cheers, Rich __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |