简体   繁体   English

boost :: serialization分割错误

[英]boost::serialization segmentation fault

Trying compile any program using boost::serialization text or binary archive with string or file stream I have segmentation fault error. 尝试使用boost::serialization文本或带有字符串或文件流的二进制归档文件编译任何程序,我遇到分段错误错误。 Even for the simple code like: 即使对于简单的代码,例如:

#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <sstream>

int main()
{
  std::stringstream ss;
  {
    try
    {
      boost::archive::binary_oarchive oa(ss);
    }
    catch(...) {}
  }
}

Error: 错误:

received signal SIGSEGV, Segmentation fault.
In ?? () ()
#1  0x00007ffff79ad770 in sputn (__n=8, __s=0x7fffffffd990 "\026", this=<optimized out>) at /usr/include/c++/4.8/streambuf:451
/usr/include/c++/4.8/streambuf:451:15915:beg:0x7ffff79ad770
At /usr/include/c++/4.8/streambuf:451
#1  0x00007ffff79ad770 in sputn (__n=8, __s=0x7fffffffd990 "\026", this=<optimized out>) at /usr/include/c++/4.8/streambuf:451
/usr/include/c++/4.8/streambuf:451:15915:beg:0x7ffff79ad770

Boost 1.59 installed on Ubuntu trusty as Boost 1.59安装在Ubuntu Trusty上

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

Why it can be so? 为什么会这样呢?

After manual boost installation on ubuntu, program was linked with wrong libraries. 在ubuntu上手动安装Boost之后,程序与错误的库链接。 There was another copy of boost, installed in /usr/lib/x86_64-linux-gnu directory, which had higher priority for linker. 在/ usr / lib / x86_64-linux-gnu目录中安装了boost的另一个副本,该副本的链接程序优先级更高。 On Ubuntu default boost installations from repository are multiarch, 64 bit version for Intel processors is installed in /usr/lib/x86_64-linux-gnu and may be several versions for several architectures on the same machine. 在Ubuntu上,来自存储库的默认Boost安装是多体系的,用于Intel处理器的64位版本安装在/ usr / lib / x86_64-linux-gnu中,并且可能是同一台计算机上几种体系结构的多个版本。

As a variant of simple manual boost installation (actual for 1.59): 作为简单的手动增强安装的变体(实际适用于1.59):

./bootstrap.sh --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
sudo ./b2 install

bash shell commands from the boost unpacked source directory. 来自boost解压缩源目录的bash shell命令。

This will install boost in standard directories, used and by standard boost packages from repository. 这会将boost安装在标准目录中,并由存储库中的标准boost软件包使用和安装。 (And may be potentially may cause some conflicts with standard packages) (并且可能潜在地导致与标准软件包的某些冲突)

Or install boost in some directory and do it visible for linker with some standard way. 或在某些目录中安装boost,并以某种标准方式使其对链接器可见。 Or link directly to the installed libraries, eg use /usr/lib/libboost_serialization.so or /usr/lib/libboost_serialization.a and not -lboost_serialization linker options. 或直接链接到已安装的库,例如,使用/usr/lib/libboost_serialization.so或/usr/lib/libboost_serialization.a,而不使用-lboost_serialization链接器选项。

Thanks to all for help. 感谢大家的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM