From: richard a. <ric...@ya...> - 2006-10-14 20:47:56
|
I upgraded to SWIG 1.3.29, as Geoff suggested. After compiling the swig wrapper, I still get a segfault on loading the Ruby module. Before submitting a bug report to SWIG, I wanted to make sure I was doing this correctly. So here is my process in detail. I'm using Open Babel 2.0.2, Ruby 1.8.5, and Mandriva Linux 2007 amd64. (1) ./configure, make, and (as root) make install OB (2) cd into OPENBABEL/scripts (3) edit openbabel.i: comment out line 27 (Swig can't find std_list.i for Ruby - it works for Python, though). Change line 5 to %module openbabel_wrap (don't want to risk a collision w/ installed openbabel library) (4) generate the SWIG wrapper: swig -ruby -c++ -I../src openbabel.i This generates lots of warnings that don't appear when the argument is -python instead of -ruby (maybe this is the problem): ../src/math/vector3.h:114: Warning(389): operator[] ignored (consider using %extend) ../src/math/vector3.h:123: Warning(362): operator= ignored ../src/math/vector3.h:130: Warning(378): operator!= ignored ../src/math/vector3.h:180: Warning(365): operator+= ignored ../src/math/vector3.h:187: Warning(366): operator-= ignored ../src/math/vector3.h:194: Warning(365): operator+= ignored ../src/math/vector3.h:201: Warning(366): operator-= ignored ../src/math/vector3.h:208: Warning(367): operator*= ignored ../src/math/vector3.h:215: Warning(368): operator/= ignored ../src/math/vector3.h:217: Warning(367): operator*= ignored ../src/bitvec.h:121: Warning(362): operator= ignored ../src/bitvec.h:122: Warning(371): operator&= ignored ../src/bitvec.h:123: Warning(372): operator|= ignored ../src/bitvec.h:128: Warning(372): operator|= ignored ../src/bitvec.h:129: Warning(370): operator^= ignored ../src/bitvec.h:130: Warning(366): operator-= ignored ../src/bitvec.h:131: Warning(365): operator+= ignored ../src/bitvec.h:136: Warning(389): operator[] ignored (consider using %extend) ../src/generic.h:152: Warning(362): operator= ignored ../src/generic.h:170: Warning(362): operator= ignored ../src/generic.h:279: Warning(362): operator= ignored ../src/generic.h:310: Warning(362): operator= ignored ../src/generic.h:364: Warning(362): operator= ignored ../src/generic.h:399: Warning(362): operator= ignored ../src/generic.h:437: Warning(362): operator= ignored ../src/generic.h:483: Warning(362): operator= ignored ../src/generic.h:531: Warning(362): operator= ignored ../src/generic.h:567: Warning(362): operator= ignored ../src/generic.h:598: Warning(362): operator= ignored ../src/mol.h:87: Warning(362): operator= ignored ../src/mol.h:233: Warning(362): operator= ignored ../src/mol.h:785: Warning(362): operator= ignored ../src/mol.h:786: Warning(365): operator+= ignored ../src/ring.h:62: Warning(362): operator= ignored ../src/parsmart.h:207: Warning(362): operator= ignored ../src/oberror.h:162: Warning(401): Nothing known about base class 'std::stringbuf'. Ignored. ../src/obconversion.h:175: Warning(401): Nothing known about base class 'std::binary_function<char const *,char const *,bool >'. Ignored. ../src/obconversion.h:175: Warning(401): Maybe you forgot to instantiate 'std::binary_function<char const *,char const *,bool >' using %template. openbabel.i:33: Warning(801): Wrong class name (corrected to `VectorInt') openbabel.i:33: Warning(801): Wrong class name (corrected to `VectorInt') openbabel.i:34: Warning(801): Wrong class name (corrected to `VvInt') openbabel.i:34: Warning(801): Wrong class name (corrected to `VvInt') openbabel.i:35: Warning(801): Wrong class name (corrected to `VectorDouble') openbabel.i:35: Warning(801): Wrong class name (corrected to `VectorDouble') openbabel.i:36: Warning(801): Wrong class name (corrected to `VVector3') openbabel.i:36: Warning(801): Wrong class name (corrected to `VVector3') openbabel.i:38: Warning(801): Wrong class name (corrected to `VectorMol') openbabel.i:38: Warning(801): Wrong class name (corrected to `VectorMol') openbabel.i:39: Warning(801): Wrong class name (corrected to `VectorBond') openbabel.i:39: Warning(801): Wrong class name (corrected to `VectorBond') openbabel.i:40: Warning(801): Wrong class name (corrected to `VectorResidue') openbabel.i:40: Warning(801): Wrong class name (corrected to `VectorResidue') openbabel.i:41: Warning(801): Wrong class name (corrected to `VectorRing') openbabel.i:41: Warning(801): Wrong class name (corrected to `VectorRing') ../src/math/vector3.h:57: Warning(801): Wrong class name (corrected to `Vector3') ../src/math/vector3.h:57: Warning(801): Wrong class name (corrected to `Vector3') ../src/math/vector3.h:126: Warning(503): Can't wrap 'operator <<' unless renamed to a valid identifier. ../src/math/vector3.h:129: Warning(503): Can't wrap 'operator ==' unless renamed to a valid identifier. ../src/math/vector3.h:137: Warning(503): Can't wrap 'operator +' unless renamed to a valid identifier. ../src/math/vector3.h:142: Warning(503): Can't wrap 'operator -' unless renamed to a valid identifier. ../src/math/vector3.h:147: Warning(503): Can't wrap 'operator -' unless renamed to a valid identifier. ../src/math/vector3.h:152: Warning(503): Can't wrap 'operator *' unless renamed to a valid identifier. ../src/math/vector3.h:157: Warning(503): Can't wrap 'operator *' unless renamed to a valid identifier. ../src/math/vector3.h:162: Warning(503): Can't wrap 'operator /' unless renamed to a valid identifier. ../src/math/vector3.h:171: Warning(503): Can't wrap 'operator *' unless renamed to a valid identifier. ../src/math/vector3.h:225: Warning(503): Can't wrap 'OpenBabel::dot' unless renamed to a valid identifier. ../src/math/vector3.h:228: Warning(503): Can't wrap 'OpenBabel::cross' unless renamed to a valid identifier. ../src/math/vector3.h:231: Warning(503): Can't wrap 'OpenBabel::vectorAngle' unless renamed to a valid identifier. ../src/math/vector3.h:235: Warning(503): Can't wrap 'OpenBabel::CalcTorsionAngle' unless renamed to a valid identifier. ../src/oberror.h:162: Warning(801): Wrong class name (corrected to `ObLogBuf') (5) create a new directory called "ruby" (6) move openbabel_wrap.cxx, generated from SWIG, into the ruby directory (7) cd into ruby directory (8) save the following as "extconf.rb": require 'mkmf' dir_config('openbabel') dir_config('openbabel-2.0') have_library('openbabel') create_makefile('openbabel_wrap') (9) create the makefile: ruby extconf.rb --with-openbabel-include='/usr/local/include/openbabel-2.0/openbabel' --with-openbabel-2.0-include='/usr/local/include/openbabel-2.0' this produces: checking for main() in -lopenbabel... yes creating Makefile and creates "Makefile" (10) add the following to line 10 of openbabel_wrap.cxx: #include <math.h> (11) make. This generates the following messages: g++ -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux-gnu -I. -I/usr/local/include/openbabel-2.0 -I/usr/local/include/openbabel-2.0/openbabel -fPIC -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -Wall -fPIC -c openbabel_wrap.cxx In file included from /usr/local/include/openbabel-2.0/openbabel/obutil.h:23, from openbabel_wrap.cxx:1648: /usr/local/include/openbabel-2.0/openbabel/babelconfig.h:18:1: warning: "EXTERN" redefined In file included from /usr/lib/ruby/1.8/x86_64-linux-gnu/ruby.h:28, from openbabel_wrap.cxx:809: /usr/lib/ruby/1.8/x86_64-linux-gnu/defines.h:203:1: warning: this is the location of the previous definition openbabel_wrap.cxx: In function int SWIG_AsPtr_std_string(VALUE, std::string**): openbabel_wrap.cxx:2186: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vectorInt__SWIG_3(int, VALUE*, VALUE): openbabel_wrap.cxx:2455: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vectorInt(int, VALUE*, VALUE): openbabel_wrap.cxx:2509: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vectorInt___len__(int, VALUE*, VALUE): openbabel_wrap.cxx:2568: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vectorInt_emptyq___(int, VALUE*, VALUE): openbabel_wrap.cxx:2604: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vvInt__SWIG_2(int, VALUE*, VALUE): openbabel_wrap.cxx:2874: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vvInt__SWIG_3(int, VALUE*, VALUE): openbabel_wrap.cxx:2918: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:2922: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vvInt(int, VALUE*, VALUE): openbabel_wrap.cxx:2969: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:2978: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:3014: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vvInt___len__(int, VALUE*, VALUE): openbabel_wrap.cxx:3050: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:3054: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vvInt_emptyq___(int, VALUE*, VALUE): openbabel_wrap.cxx:3082: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:3086: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vvInt_push(int, VALUE*, VALUE): openbabel_wrap.cxx:3149: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vvInt___setitem__(int, VALUE*, VALUE): openbabel_wrap.cxx:3273: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vectorDouble__SWIG_3(int, VALUE*, VALUE): openbabel_wrap.cxx:3429: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vectorDouble(int, VALUE*, VALUE): openbabel_wrap.cxx:3483: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vectorDouble___len__(int, VALUE*, VALUE): openbabel_wrap.cxx:3542: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vectorDouble_emptyq___(int, VALUE*, VALUE): openbabel_wrap.cxx:3578: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vVector3__SWIG_3(int, VALUE*, VALUE): openbabel_wrap.cxx:3883: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:3887: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vVector3(int, VALUE*, VALUE): openbabel_wrap.cxx:3934: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:3943: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vVector3___len__(int, VALUE*, VALUE): openbabel_wrap.cxx:3993: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:3997: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vVector3_emptyq___(int, VALUE*, VALUE): openbabel_wrap.cxx:4025: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:4029: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vectorMol__SWIG_3(int, VALUE*, VALUE): openbabel_wrap.cxx:4343: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:4347: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vectorMol(int, VALUE*, VALUE): openbabel_wrap.cxx:4394: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:4403: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vectorMol___len__(int, VALUE*, VALUE): openbabel_wrap.cxx:4453: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:4457: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vectorMol_emptyq___(int, VALUE*, VALUE): openbabel_wrap.cxx:4485: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:4489: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vectorBond__SWIG_3(int, VALUE*, VALUE): openbabel_wrap.cxx:4803: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:4807: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vectorBond(int, VALUE*, VALUE): openbabel_wrap.cxx:4854: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:4863: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vectorBond___len__(int, VALUE*, VALUE): openbabel_wrap.cxx:4913: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:4917: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vectorBond_emptyq___(int, VALUE*, VALUE): openbabel_wrap.cxx:4945: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:4949: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vectorResidue__SWIG_3(int, VALUE*, VALUE): openbabel_wrap.cxx:5263: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:5267: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vectorResidue(int, VALUE*, VALUE): openbabel_wrap.cxx:5314: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:5323: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vectorResidue___len__(int, VALUE*, VALUE): openbabel_wrap.cxx:5373: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:5377: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vectorResidue_emptyq___(int, VALUE*, VALUE): openbabel_wrap.cxx:5405: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:5409: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vectorRing__SWIG_3(int, VALUE*, VALUE): openbabel_wrap.cxx:5723: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:5727: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_new_vectorRing(int, VALUE*, VALUE): openbabel_wrap.cxx:5774: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:5783: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vectorRing___len__(int, VALUE*, VALUE): openbabel_wrap.cxx:5833: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:5837: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx: In function VALUE _wrap_vectorRing_emptyq___(int, VALUE*, VALUE): openbabel_wrap.cxx:5865: warning: dereferencing type-punned pointer will break strict-aliasing rules openbabel_wrap.cxx:5869: warning: dereferencing type-punned pointer will break strict-aliasing rules gcc -shared -L"/usr/lib64" -o openbabel_wrap.so openbabel_wrap.o -lruby -lopenbabel -lpthread -ldl -lcrypt -lm -lc The following files are created: openbabel_wrap.o openbabel_wrap.so (12) irb (13) require 'openbabel_wrap' produces: irb(main):001:0> require 'openbabel_wrap' (eval): [BUG] Segmentation fault ruby 1.8.5 (2006-08-25) [x86_64-linux-gnu] Aborted As I mentioned before, if I remove the OBAtom, OBBond, and OBMol definitions from Init_openbabel_wrap (last function), the Ruby module is loaded without segfaulting. I can also remove everything from the respective stanzas except the first line and still I get a segfault, so I'm guessing this is where the error happens. Would someone be willing to go through this series of steps to verify that the problem is not related to my system's configuration (my version of Ruby, my platform, my compiler, etc.) cheers, Rich __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |