c++ 使用boost编译时出现序列化错误

6fe3ivhb  于 2023-06-25  发布在  其他
关注(0)|答案(2)|浏览(339)

我正在尝试编译一个用C编写的名为Bagel的软件(一个量子化学程序,一些信息是here),它使用Boost。
我得到一个编译错误,因为我不知道C
,我从来没有使用过boost,我基本上迷路了。程序的作者说我遇到的问题取决于我的boost安装,而不是程序本身。
我安装了boost 1.73.0(Linux Mint 20,g++ 9.3.0),执行以下操作:

sudo ./bootstrap.sh --prefix=/usr/local
sudo ./b2 install

编译程序时,我得到以下错误:

/usr/local/include/boost/serialization/access.hpp:119:11: error: ‘class std::unordered_set<long unsigned int>’ has no member named ‘serialize’
  119 |         t.serialize(ar, file_version);
      |         ~~^~~~~~~~~
/usr/local/include/boost/serialization/access.hpp: In instantiation of ‘static void boost::serialization::access::serialize(Archive&, T&, unsigned
 int) [with Archive = boost::archive::binary_oarchive; T = std::unordered_set<long unsigned int>]’:
/usr/local/include/boost/serialization/serialization.hpp:69:22:   required from ‘void boost::serialization::serialize(Archive&, T&, unsigned int) 
[with Archive = boost::archive::binary_oarchive; T = std::unordered_set<long unsigned int>]’
/usr/local/include/boost/serialization/serialization.hpp:128:18:   required from ‘void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_oarchive; T = std::unordered_set<long unsigned int>]’
/usr/local/include/boost/archive/detail/oserializer.hpp:148:40:   required from ‘void boost::archive::detail::oserializer<Archive, T>::save_object_data(boost::archive::detail::basic_oarchive&, const void*) const [with Archive = boost::archive::binary_oarchive; T = std::unordered_set<long unsigned int>]’
/usr/local/include/boost/archive/detail/oserializer.hpp:101:1:   required from ‘class boost::archive::detail::oserializer<boost::archive::binary_oarchive, std::unordered_set<long unsigned int> >’
/usr/local/include/boost/archive/detail/oserializer.hpp:253:13:   required from ‘static void boost::archive::detail::save_non_pointer_type<Archive>::save_standard::invoke(Archive&, const T&) [with T = std::unordered_set<long unsigned int>; Archive = boost::archive::binary_oarchive]’
/usr/local/include/boost/archive/detail/oserializer.hpp:308:22:   [ skipping 21 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
...

下面的帖子https://lists.boost.org/boost-users//2014/03/81583.php报告了一个类似的错误,但我不明白我应该怎么解决它。* 任何 * 帮助将不胜感激!

n1bvdmb6

n1bvdmb61#

要求说
Boost C++ Libraries -版本1.53.0或更新版本
Boost以进行非向后兼容的更改而闻名。1.73与1.53相差甚远。我会尝试安装百吉饼的作者不得不使用的1.53,这一个至少对他/她有效。

wqsoz72f

wqsoz72f2#

为了记录在案,我在使用Boost的v1.53.0编译Bagel时得到了类似的错误消息(见下文)。然而,当使用Boost v1.70.0(以下是这条评论)时,我再也没有得到错误。
我能够在CentOS 7上使用gcc 7.3.1和英特尔OneAPI 2021.3成功编译Bagel,以及在Ubuntu 20.04上使用gcc 9.4.0和相同版本的英特尔OneAPI。
另一个注意事项是,我从源代码构建Boost,因为configure没有找到包管理器提供的库文件(它希望头文件在$BOOST_ROOT/include中,库文件在$BOOST_ROOT/lib中)。

libtool: compile: mpicxx -DHAVE_CONFIG_H -I. -I../../../src/smith -I../..
-I/opt/boost/include -I../../.. -DNDEBUG -O3 -mavx -MT tensor.lo -MD -MP -MF 
.deps/tensor.Tpo -c ../../../src/smith/tensor.cc -fPIC -DPIC -o .libs/tensor.o

In file included from
/usr/include/boost/serialization/split_member.hpp:23:0,

... (lots of lines)

/usr/include/boost/serialization/access.hpp:118:11: error: 'class
std::unordered_set<long unsigned int>' has no member named 'serialize'
t.serialize(ar, file_version); ~~^~~~~~~~~

相关问题