I'm jira. I try to implement babel in c++ in order to convert a file of chemical structures in 'mol' format to that in 'smiles' format. I wrote the code similar to the one provided in documentation of openbabel ( http://openbabel.org/docs/dev/UseTheLibrary/CppExamples.html ) as follows.
#include <openbabel/obconversion.h>
#include <fstream>
int main(int argc, char **argv){
std::ifstream ifs("a.mol");
std::ofstream ofs("a.smi");
OpenBabel::OBConversion conv(&ifs, &ofs);
conv.setInAndOutFormats("MOL","SMI");
int n = conv.Convert();
std::out << n << " molecules are converted.\n"
return 1;
}
but it always prints
0 molecules are converted.
and return an empty file "a.smi".
However, when I implement babel at the command line, e.g.
babel -imol a.mol -osmi
it works fine.
I would like ask if anyone has been experienced this kind of error and how you solved it. Because I follows all the things provided in documentation, I cannot figure out the reason of this error.
Thank you very much in advance.
Jira