[Open Babel] Re: Writing code against openbabel

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Open Babel] Re: Writing code against openbabel

Geoffrey Hutchison
Andrew,

I hope you don't mind me replying on-list, because I think this might  
be a more common question for people writing and using the 2.0 code.  
I heard from Chris Morley about your difficulties compiling OpenBabel  
with STLPort -- hopefully we can make that easier.

What I don't know is what compilation environment you were using on  
Windows. I don't think it was Cygwin (with GCC). Did you install Open  
Babel? Under UNIX, the file format libraries are expected to be in a  
standard location which happens with a "make install." Looking at the  
Windows format code, that seems to be true as well.

Perhaps Chris Morley can help here -- I don't know enough about the  
Windows compilers to know this bit:
     HMODULE hConv = GetModuleHandle("OBConv");
     GetModuleFileName(hConv,path,MAX_PATH);

It looks like it's trying to find the OBConv.dll module and look for  
file format libraries in that directory?

Cheers,
-Geoff


On Oct 27, 2005, at 8:10 AM, Smellie, Andrew wrote:


> Geoff
>
> I need your help. After quite some effort I compiled and linked
> OpenBabel on Windows. When I try to run this simple piece of code:
>
> 1    OBConversion conv(instrm,0);
> 2    if( conv.SetInAndOutFormats("SMI","MOL") ) {
> 3        obmol = new OBMol;
> 4        if(conv.Read(obmol)) {
> 5           // ...manipulate molecule
> 6        }
> 7        delete obmol;
> 8    }
>
> line 2 returns FALSE...nothing happens. Poking around in the code,  
> I'm suspecting
> there is some environmental setup required...perhaps an environment  
> variable that
> points to some installation directory with data files?
>
> I do not intend to ouput anything, so I left the output stream as  
> NULL in line 1
>
> What assumptions is openbabel making about data files locations,  
> format files etc?
>
> Thanks
>
> Andrew
>




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|

Re: [Open Babel] Re: Writing code against openbabel

Chris Morley-3
Andrew

I'm glad you managed to eventually compile OpenBabel - I
assume with VC6. It sounds as if you are using the DLL
version, but I haven't seen your complete email, only what
is below. Rather than link with the DLL files at run time
(which I deduce from the GetModuleHandle() etc code), it
is easier to link to obdll.lib and obconv.lib when the exe
file is built. You then also need OBDLL.dll, OBConv.dll
either in the same folder or in a folder in your PATH
environmental variable (or in some Windows folders, not
recommended). The format classes are in *.obf files which
are also DLLs. At start up the program looks for any obf
files it can find in the same folder as the exe file and
loads them.  It sounds as if your problem is that the one
with SMI and MOL formats, which is OBFormats2.obf, is
missing. Data files *.txt also need to be in the exe
folder but are mostly optional - there are default
versions built into the program.

The ProgramTest project illustrates this type of
application and has a post-build step which ensures that
the DLLs are copied. It would be possible to copy this
project into a folder at the same level and modify it from
there.

Another possibility is to modify OBabel project by
replacing the main.cpp with your code. This builds a
(nearly) standalone exe file with all the formats in it.
(Actually it needs libinchi.dll(from NIST) in the same
folder or on the path.)

Let me know if you run into any other problems. I need to
document the build process more fully. I would also like
to make some changes to the code so that it can be
compiled with STLPort. Would you still have the compiler
error messages and be willing to try the code when it is
modified?

Chris

Geoffrey Hutchison wrote:

> Andrew,
>
> I hope you don't mind me replying on-list, because I think this might  
> be a more common question for people writing and using the 2.0 code.  I
> heard from Chris Morley about your difficulties compiling OpenBabel  
> with STLPort -- hopefully we can make that easier.
>
> What I don't know is what compilation environment you were using on  
> Windows. I don't think it was Cygwin (with GCC). Did you install Open  
> Babel? Under UNIX, the file format libraries are expected to be in a  
> standard location which happens with a "make install." Looking at the  
> Windows format code, that seems to be true as well.
>
> Perhaps Chris Morley can help here -- I don't know enough about the  
> Windows compilers to know this bit:
>     HMODULE hConv = GetModuleHandle("OBConv");
>     GetModuleFileName(hConv,path,MAX_PATH);
>
> It looks like it's trying to find the OBConv.dll module and look for  
> file format libraries in that directory?
>
> Cheers,
> -Geoff
>
>
> On Oct 27, 2005, at 8:10 AM, Smellie, Andrew wrote:
>
>
>> Geoff
>>
>> I need your help. After quite some effort I compiled and linked
>> OpenBabel on Windows. When I try to run this simple piece of code:
>>
>> 1    OBConversion conv(instrm,0);
>> 2    if( conv.SetInAndOutFormats("SMI","MOL") ) {
>> 3        obmol = new OBMol;
>> 4        if(conv.Read(obmol)) {
>> 5           // ...manipulate molecule
>> 6        }
>> 7        delete obmol;
>> 8    }
>>
>> line 2 returns FALSE...nothing happens. Poking around in the code,  
>> I'm suspecting
>> there is some environmental setup required...perhaps an environment  
>> variable that
>> points to some installation directory with data files?
>>
>> I do not intend to ouput anything, so I left the output stream as  
>> NULL in line 1
>>
>> What assumptions is openbabel making about data files locations,  
>> format files etc?
>>
>> Thanks
>>
>> Andrew
>>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the JBoss Inc.
> Get Certified Today * Register for a JBoss Training Course
> Free Certification Exam for All Training Attendees Through End of 2005
> Visit http://www.jboss.com/services/certification for more information
> _______________________________________________
> OpenBabel-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss