Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用boost编写xml映射_Xml_C++11_Boost_Boost Serialization - Fatal编程技术网

使用boost编写xml映射

使用boost编写xml映射,xml,c++11,boost,boost-serialization,Xml,C++11,Boost,Boost Serialization,我已经使用下面的代码编写了一个映射到xml文件,但是我无法成功编译代码,我实际上是在mac sierras终端上编译这个 你能告诉我哪里出了问题吗 #include <fstream> #include <boost/serialization/map.hpp> #include <boost/serialization/nvp.hpp> #include <boost/archive/xml_oarchive.hpp> using namespa

我已经使用下面的代码编写了一个映射到xml文件,但是我无法成功编译代码,我实际上是在mac sierras终端上编译这个

你能告诉我哪里出了问题吗

#include <fstream>
#include <boost/serialization/map.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/archive/xml_oarchive.hpp>
using namespace std;

class MyConnections  
{
public:
MyConnections()
{
   m_connections["one"]= "one";
}

template<class archive>
void serialize(archive& ar, const unsigned int version)
{
    using boost::serialization::make_nvp;
    ar & make_nvp("Connections", m_connections);
}

public:
 map<string,string> m_connections ;
}; 

int main(int argc, char* argv[])
{
std::ofstream ofs("output.xml");
const MyConnections conn;

boost::archive::xml_oarchive xml(ofs);
xml << boost::serialization::make_nvp("Connections", conn);
}
#包括
#包括
#包括
#包括
使用名称空间std;
类MyConnections
{
公众:
MyConnections()
{
m_连接[“一”]=“一”;
}
模板
无效序列化(存档和ar,常量未签名整数版本)
{
使用boost::serialization::make_nvp;
ar&make_nvp(“连接”,m_连接);
}
公众:
映射m_连接;
}; 
int main(int argc,char*argv[])
{
std::ofs流(“output.xml”);
常量MyConnections conn;
boost::archive::xml\u-oarchivexml(ofs);
xml,std:::::uuu 1::basic_ustring,std::uu 1::allocator>,std::uu 1::allocator>,std::u 1::allocator,std::u 1::allocator>const,std:u 1::basic_ustring,std:u 1::allocator>>>:teee-a553d7.o中的扩展类型信息类型ID()
boost::serialization::extended_type_info_typeid,std::_1::allocator>const,std::_1::basic_string,std:::_1::allocator>>::teee-a553d7.o中的extended_type_info_typeid()
“boost::serialization::typeid_system::extended_type_info_typeid_0::type_unregister()”,引用自:
boost::serialization::extended_type_info_typeid::~teee-a553d7.o中的extended_type_info_typeid()
boost::serialization::extended_type_info_typeid,std:_1::allocator>,std:_1::basic_string,std:_1::allocator>,std:_1::less,std:_1::allocator>,std:_1::allocator,std:_1::allocator>const,std:_1::basic_string,std:_1::allocator>,std:_1::allocator>~extended:_typeid:(TEEU-53;-537
boost::serialization::extended_type_info_typeid,std::_1::allocator>const,std:_1::basic_string,std::_1::allocator>>>:~ teee-a553d7.o中的extended_type_info_typeid()
“boost::serialization::typeid_system::extended_type_info_typeid_0::extended_type_info_typeid_0(char const*)”,引用自:
teee-a553d7.o中的boost::serialization::extended_type_info_typeid::extended_type_info_typeid()
boost::serialization::extended_type_info_typeid,std:_1::allocator>,std:_1::basic_string,std:_1::allocator>,std:_1::less,std:_1::allocator>,std:_1::allocator,std:_1::allocator>const,std:_1::basic_string,std:_1::allocator>:TEEU-537中的extended:_type_信息

在Unix的官方版本中,阅读关于哪些库是单独构建的。
另请阅读链接和库命名。

Boost serialization不是一个只包含标题的库,因此您必须在链接器命令行上指定Boost-lib路径,还可能指定Boost-serialization的.lib文件。我是一个Windows用户,因此无法提供更具体的帮助。可能重复
clang++-3.8 boost_serialization_test.cpp -lboost_serialization