Compilation error in openbabel-2.3.2-patched
Brought to you by:
igor_filippov
Package openbabel-2.3.2-patched was downloded from OSRA.
$ make > produced this error:
openbabel-2.3.2-patched/include/openbabel/shared_ptr.h:27:14: error: ‘std::tr1’ has not been declared
using std::tr1::shared_ptr;
$ gcc --version
gcc (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2)
$ cat /etc/os-release
NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
Googling around did not help much. Please advice.
Thanks for your help!
try this version of openbabel:
https://sourceforge.net/projects/osra/files/openbabel-patched/openbabel-2.3.2-tr1-memory.tgz/download
This one fails with another error:
/openbabel-2.3.2-tr1-memory/src/alias.cpp: In static member function ‘static bool OpenBabel::AliasData::LoadFile(OpenBabel::AliasData::SmartsTable&)’:
/home/ec2-user/openbabel-2.3.2-tr1-memory/src/alias.cpp:273:9: error: reference to ‘shared_ptr’ is ambiguous
shared_ptr<obsmartspattern> psp(new OBSmartsPattern);
^~~~~~~~~~</obsmartspattern>
Could this be because of the compiler I am using? I tried setting it to different standards 11, 14, and 98. Makes no change.
I can install latest offical openbabel-2.4 but will the unpatched version work with OSRA?
UPD on ambiguous shared_ptr.
Solved by updating code:
shared_ptr<...>
to
std::tr1::shared_ptr<...>
The only remaining issue is this:
/home/ec2-user/openbabel-2.3.2-tr1-memory/src/ops/sort.cpp: In member function ‘virtual bool OpenBabel::OpSort::ProcessVec(std::vector<openbabel::obbase*>&)’:
/home/ec2-user/openbabel-2.3.2-tr1-memory/src/ops/sort.cpp:117:99: error: no matching function for call to ‘make_pair<openbabel::obbase*, double="">(OpenBabel::OBBase&, double)’
valvec.push_back(std::make_pair<obbase*,double>(</obbase*,double>iter, _pDesc->Predict(*iter, &_pDescOption)));
^
In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0,
from /usr/include/c++/7/bits/char_traits.h:39,
from /usr/include/c++/7/string:40,
from /home/ec2-user/openbabel-2.3.2-tr1-memory/include/openbabel/op.h:23,
from /home/ec2-user/openbabel-2.3.2-tr1-memory/src/ops/sort.cpp:19:
/usr/include/c++/7/bits/stl_pair.h:519:5: note: candidate: template<class _t2="" class="" _t1,=""> constexpr std::pair<typename std::__decay_and_strip<_tp="">::type, typename std::decay_and_strip<_T2>::type> std::make_pair(_T1&&, _T2&&)
make_pair(_T1&& x, _T2&& __y)</typename></class></openbabel::obbase*,></openbabel::obbase*>
Any recommendation would be appreciated.
why don't you try replacing it with std::make_pair as the error message suggest?
It is already so:
valvec.push_back(std::make_pair<obbase*,double>(iter, _pDesc->Predict(iter, &_pDescOption)));</obbase*,double>
it builds for me but looking at that line it seems that make_pair is redundant and could be just a call to std::pair the way it's written.
Thanks Igor.
I am past this problem now. All I needed to do is remove <type, type=""> from the call to make_pair and compiler was happy with it. </type,>
But now I am facing this problem with /formats/chemkinformat.cpp:
/home/ec2-user/openbabel-2.3.2-tr1-memory/src/formats/chemkinformat.cpp: In member function ‘bool OpenBabel::ChemKinFormat::ReadReactionQualifierLines(std::istream&, OpenBabel::OBReaction*)’:
/home/ec2-user/openbabel-2.3.2-tr1-memory/src/formats/chemkinformat.cpp:642:13: error: no match for ‘operator!=’ (operand types are ‘std::istream {aka std::basic_istream<char>}’ and ‘long int’)
return ifs!=NULL;
^</char>
Which looks like a bug described here:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216036
I am afraid my knowledge may be not enough to address this problem.
Just in case, could you share the version of gcc and stdlib that you have and which allow you to build it as is, without modifications I made?
I have it built on ubuntu 16.04 with g++ 5.4
Problem solved! I successfully compiled patched tr1 version. In the nutshell, I needed to change:
if(stream) ...
Thanks!
Great - glad to hear this!