c – 错误:’make_array’不是’boost :: serialization的成员

前端之家收集整理的这篇文章主要介绍了c – 错误:’make_array’不是’boost :: serialization的成员前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我无法编译 basic boost vector example.
我在Windows 10上,我使用的是 nuwen MinGW distro版本15.0,不包含git.此版本包含GCC 7.10和Boost 1.64.我已经解压缩MinGw并将其放在我的文件系统的根目录中,并且我遵循MinGW使用说明A来运行set_distro_paths.bat.下面是代码,它无法在我的系统上构建:

矢量fail.cpp:

#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/io.hpp>

int main () {
    using namespace boost::numeric::ublas;
    vector<double> v (3);
    for (unsigned i = 0; i < v.size (); ++ i)
        v (i) = i;
    std::cout << v << std::endl;
}

Makefile文件

vector-fail: vector-fail.o
    g++ vector-fail.o -o vector-fail
vector-fail.o: vector-fail.cpp
    g++ -c vector-fail.cpp -o vector-fail.o

输出

g++ -c vector-fail.cpp -o vector-fail.o
In file included from C:\MinGW\include/boost/numeric/ublas/vector.hpp:21:0,from vector-fail.cpp:1:
C:\MinGW\include/boost/numeric/ublas/storage.hpp: In member function 'void 
boost::numeric::ublas::unbounded_array<T,ALLOC>::serialize(Archive&,unsigned int)':
C:\MinGW\include/boost/numeric/ublas/storage.hpp:299:33: error: 'make_array' is not a member of 'boost::serialization'
              ar & serialization::make_array(data_,s);
                                  ^~~~~~~~~~
C:\MinGW\include/boost/numeric/ublas/storage.hpp:299:33: note: suggested alternative: 'make_nvp'
             ar & serialization::make_array(data_,s);
                                 ^~~~~~~~~~
                             make_nvp
C:\MinGW\include/boost/numeric/ublas/storage.hpp: In member function 'void boost::numeric::ublas::bounded_array<T,N,unsigned int)':
C:\MinGW\include/boost/numeric/ublas/storage.hpp:494:33: error: 'make_array' is not a member of 'boost::serialization'
             ar & serialization::make_array(data_,s);
                                 ^~~~~~~~~~
C:\MinGW\include/boost/numeric/ublas/storage.hpp:494:33: note: suggested alternative: 'make_nvp'
             ar & serialization::make_array(data_,s);
                                 ^~~~~~~~~~
                                 make_nvp
make: *** [Makefile:5: vector-fail.o] Error 1

不幸的是,我的代码中没有出现这些错误,而是由boost库中的include文件中的文件引起的.可以在应用程序级代码或Makefile中进行哪些更改以允许程序编译?

解决方法

是的,这是ublas标题的问题.我之前遇到过它.您可以通过包含来解决
#include <boost/serialization/array_wrapper.hpp>

在那之前.我会考虑将其报告给ublas代码的维护者.

猜你在找的C&C++相关文章