Hi, You should add the hack in your module code. You do not modify or recompile OB.
I'm using this fix with Mychem . It works perfectly: http://mychem.svn.sourceforge.net/viewvc/mychem/mychem3/src/conversion_wrapper.cpp?revision=325&view=markup Jerome Le jeudi 18 novembre 2010 10:12:11, Imran Haque a écrit : > Hi Jerome, > > Thanks for the suggestion. I'm actually building under x84_64 Linux, so > neither the Cygwin nor MinGW flags will be active, but maybe this is > still the right way to get around it. It certainly seems like some > function pointer table is not getting initialized (the effects seem > similar to not calling _import_array() for Numpy C-API code). Where > would I add the PLUGIN_CPP_FILE macro - to the OB source tree, or > somewhere in my module source code? A quick look at > include/openbabel/plugin.h suggests that I'd need to rebuild the OB > libraries - is this true? > > Alternatively, is there a function I can call to get the function table > set up correctly, without needing to modify OB itself? > > Thanks, > > Imran > > On 11/18/2010 01:00 AM, Jerome Pansanel wrote: > > Hi, > > > > I've faced the same problem with Mychem. You should use the following > > ack: > > > > #if defined(__CYGWIN__) || defined(__MINGW32__) > > > > // macro to implement static OBPlugin::PluginMapType& Map() > > PLUGIN_CPP_FILE(OBFormat) > > > > #endif > > > > Here is a copy of a mail from Chris about this problem: > > ========================================= > > In 2008 OBFormat was made part of the OBPlugin framework, which now > > manages the map relating the formats IDs and the pointers to the > > OBFormat objects. FormatFromMime() is a hangover from the old system, > > with its map managed by OBFormat itself. It seems the latter is > > working but the OBPlugin framework is not. > > > > Building OB on MinGW and CygWin gave similar problems with the formats > > not being visible, which Tim solved by conditional code in each plugin > > type's cpp file. See for instance line 26 of format.cpp . Maybe adding > > to the conditional to get this code to run for your build would be a > > solution. I'm afraid I don't understand how this fix works; maybe Tim > > could comment whether this would be worth trying. > > > > Chris > > ========================================= > > > > Cheers, > > > > Jerome Pansanel > > > > Le jeudi 18 novembre 2010 02:35:21, Imran Haque a écrit : > >> Hi, > >> > >> I have a large set of C++ molecule-manipulation libraries that > >> internally use OpenBabel to handle molecule input and structure, and I'm > >> trying to wrap them into a Python library using standard Python C API > >> techniques. These routines work fine when called from a C program, but > >> when called from the .so used for the Python library, > >> OBConversion::FindFormat segfaults. I don't know how to follow the code > >> path in the source code, as it appears to be generated by macros and > >> eventually calls down into an independent set of .so's for each file > >> format. Does anyone know how to get the molecule loader routines to work > >> from dynamic libraries? > >> > >> I've put up a minimal test case at > >> http://cs.stanford.edu/people/ihaque/ob_bug_repro.tar. You may have to > >> adjust the paths in the Makefile to correspond to your Python and OB > >> installations. Here's sample output (note that I added a tracing printf > >> to OBConversion::FormatFromExt that isn't in the mainline OB 2.3.0 > >> source): > >> > >> $ python numatoms.py test.sdf > >> Molecule hasFilename test.sdf > >> FormatFromExt calling FindFormat with arg sdf > >> Segmentation fault > >> > >> $ ./numatoms test.sdf > >> Filename test.sdf > >> FormatFromExt calling FindFormat with arg sdf > >> Detected format: MDL MOL format > >> Reads and writes V2000 and V3000 versions > >> Read Options, e.g. -as > >> > >> s determine chirality from atom parity flags > >> > >> This is valid only for 0D information. Atom > >> parity is always ignored on reading for MOL files > >> containing 2D or 3D information. > >> > >> T read title only > >> P read title and properties only > >> > >> When filtering an sdf file on title or properties > >> only, avoid lengthy chemical interpretation by > >> using the T or P option together with copy format. > >> > >> Write Options, e.g. -x3 > >> > >> 3 output V3000 not V2000 (used for>999 atoms/bonds) > >> m write no properties > >> w recalculate wedge and hash bonds(2D structures only) > >> A output in Alias form, e.g. Ph, if present > >> > >> Molecule has 27 atoms. > >> > >> > >> Thanks, > >> > >> Imran Haque > >> http://cs.stanford.edu/people/ihaque > >> [email protected] > >> > >> > >> PS - Using Pybel is not an option here because I don't want to > >> reimplement all the C++ functionality in Python - I just need to be able > >> to call into it. > >> > >> ------------------------------------------------------------------------ > >> --- --- Beautiful is writing same markup. Internet Explorer 9 supports > >> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2& L3. > >> Spend less time writing and rewriting code and more time creating > >> great experiences on the web. Be a part of the beta today > >> http://p.sf.net/sfu/msIE9-sfdev2dev > >> _______________________________________________ > >> OpenBabel-discuss mailing list > >> [email protected] > >> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss > > > > ------------------------------------------------------------------------- > > ----- Beautiful is writing same markup. Internet Explorer 9 supports > > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2& L3. > > Spend less time writing and rewriting code and more time creating great > > experiences on the web. Be a part of the beta today > > http://p.sf.net/sfu/msIE9-sfdev2dev > > _______________________________________________ > > OpenBabel-discuss mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss > > --------------------------------------------------------------------------- > --- Beautiful is writing same markup. Internet Explorer 9 supports > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. > Spend less time writing and rewriting code and more time creating great > experiences on the web. Be a part of the beta today > http://p.sf.net/sfu/msIE9-sfdev2dev > _______________________________________________ > OpenBabel-discuss mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss ------------------------------------------------------------------------------ Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today http://p.sf.net/sfu/msIE9-sfdev2dev _______________________________________________ OpenBabel-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
