gpt4 book ai didi

c++ - 错误链接以 boost 序列化

转载 作者:太空狗 更新时间:2023-10-29 22:58:48 25 4
gpt4 key购买 nike

当我尝试将我的 C++ 程序与英特尔 MPI 链接在一起时,我遇到了这个问题:

[key01027@ginar ising]$ mpiicc -o bin/ising obj/main.o obj/solver.o obj/periodicfunction.o obj/tools.o obj/treeofdevil.o  -L ~/ising_solver/gurobi650/linux64/lib/ -L ~/ising_solver/boost_install/lib/ -parallel -lgurobi_c++ -lgurobi65 -lboost_regex -lboost_thread -lboost_system  -lboost_mpi -lboost_serialization
obj/solver.o: In function `boost::archive::detail::iserializer<boost::mpi::packed_iarchive, std::vector<double, std::allocator<double> > >::load_object_data(boost::archive::detail::basic_iarchive&, void*, unsigned int) const':
solver.cpp:(.text._ZNK5boost7archive6detail11iserializerINS_3mpi15packed_iarchiveESt6vectorIdSaIdEEE16load_object_dataERNS1_14basic_iarchiveEPvj[_ZNK5boost7archive6detail11iserializerINS_3mpi15packed_iarchiveESt6vectorIdSaIdEEE16load_object_dataERNS1_14basic_iarchiveEPvj]+0x209): undefined reference to `boost::serialization::array_wrapper<double> const boost::serialization::make_array<unsigned long>(double*, unsigned long)'

关键错误是:

undefined reference to `boost::serialization::array_wrapper<double> const boost::serialization::make_array<unsigned long>(double*, unsigned long)'

我认为我正确安装了 boost mpi。我已经在我的链接中包含序列化 (-lboost_serialization)...我应该怎么做?

我不确定是因为下面的序列化方案,序列化boost元组:

namespace boost { namespace serialization {


template<typename Archive, typename T1>

void serialize(Archive & ar,
boost::tuple<T1> & t,

const unsigned int)
{
ar & t.get<0>();
}

template<typename Archive, typename T1,typename T2>
void serialize(Archive & ar,

boost::tuple<T1,T2> & t,

const unsigned int)
{

ar & t.get<0>();
ar & t.get<1>();
}


template<typename Archive, typename T1,typename T2,typename T3>
void serialize(Archive & ar,

boost::tuple<T1, T2, T3> & t,

const unsigned int)
{

ar & t.get<0>();
ar & t.get<1>();
ar & t.get<2>();
}


template<typename Archive, typename T1,typename T2,typename T3 ,typename T4>
void serialize(Archive & ar,

boost::tuple<T1, T2, T3 ,T4> & t,

const unsigned int)
{

ar & t.get<0>();
ar & t.get<1>();
ar & t.get<2>();
ar & t.get<3>();
}

template<typename Archive, typename T1,typename T2,typename T3 ,typename T4,typename T5>
void serialize(Archive & ar,

boost::tuple<T1, T2, T3 ,T4, T5> & t,

const unsigned int)
{

ar & t.get<0>();
ar & t.get<1>();
ar & t.get<2>();
ar & t.get<3>();
ar & t.get<4>();
}

template<typename Archive, typename T1,typename T2,typename T3 ,typename T4,typename T5,typename T6 >
void serialize(Archive & ar,

boost::tuple<T1, T2, T3 ,T4, T5, T6> & t,

const unsigned int)
{

ar & t.get<0>();
ar & t.get<1>();
ar & t.get<2>();
ar & t.get<3>();
ar & t.get<4>();
ar & t.get<5>();
}


template<typename Archive, typename T1,typename T2,typename T3 ,typename T4,typename T5,typename T6 ,typename T7>
void serialize(Archive & ar,

boost::tuple<T1, T2, T3 ,T4, T5, T6 ,T7> & t,

const unsigned int)
{

ar & t.get<0>();
ar & t.get<1>();
ar & t.get<2>();
ar & t.get<3>();
ar & t.get<4>();
ar & t.get<5>();
ar & t.get<6>();
}


}}

最佳答案

在“boost/include/boost/serialization/array.hpp”文件中,注释掉这两行:

template<class S>
friend const boost::serialization::array_wrapper<T> make_array( T* t, S s);

然后它将正常链接。

关于c++ - 错误链接以 boost 序列化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39497971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com