- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我试图找到一个很好的例子来说明如何使用这些二进制宽字符版本的 boost 序列化内容。我拼凑了一些代码来尝试让它工作,但不幸的是,我在尝试编译它时遇到了链接器错误的轰炸。
这是我的代码,以防我做任何明显错误的事情:
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <boost/archive/binary_woarchive.hpp>
#include <boost/archive/binary_wiarchive.hpp>
class testClass
{
public:
testClass()
{
}
testClass(const int intInput, const std::wstring stringInput, const float floatInput01, const float floatInput02)
{
ourString = stringInput;
testInt = intInput;
testFloat01 = floatInput01;
testFloat02 = floatInput02;
}
~testClass()
{}
int testInt;
std::wstring ourString;
float testFloat01;
float testFloat02;
int ReturnTestInt()
{
return testInt;
}
float RandomStuff()
{
float alpha01 = 26.9;
alpha01 /= 2;
return alpha01;
}
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive &ar, const unsigned int version)
{
ar &testInt;
ar &ourString;
ar &testFloat01;
ar &testFloat02;
}
};
int main()
{
std::vector<const testClass> objectStorage;
objectStorage.push_back(testClass(1, L"test\0", 9.14f, 6.662f));
objectStorage.push_back(testClass(2, L"temp\0", 0.29f, 3.331f));
objectStorage.push_back(testClass(3, L"then\0", 2.47f, 8.888f));
testClass testReceivedObject;
std::ifstream::pos_type size;
std::wofstream myFile;
boost::archive::binary_woarchive outputArchive(myFile);
myFile.open("Example.dat", std::ios::out | std::ios::binary);
if(myFile.is_open() && myFile.good())
{
std::cout<<"File opening successfully completed."<<std::endl;
unsigned int storageSize = objectStorage.size();
myFile.write(reinterpret_cast<wchar_t*>(&storageSize), (sizeof(unsigned int)));
for(int i = 0; i < objectStorage.size(); i++)
{
outputArchive<<objectStorage[i];
}
/*
myFile.write(reinterpret_cast<char*>(&objectStorage[0]), (sizeof(testClass)));
myFile.write(reinterpret_cast<char*>(&objectStorage[1]), (sizeof(testClass)));
myFile.write(reinterpret_cast<char*>(&objectStorage[2]), (sizeof(testClass)));
*/
}
else
{
std::cout<<"File opening NOT successfully completed."<<std::endl;
}
myFile.close();
std::wifstream myFileInput;
boost::archive::binary_wiarchive inputArchive(myFileInput);
myFileInput.open("Example.dat", std::ios::in | std::ios::binary | std::ios::ate);
if(myFileInput.is_open() && myFileInput.good())
{
std::cout<<"File opening successfully completed. Again."<<std::endl;
std::cout<<"READ:"<<std::endl;
size = myFileInput.tellg();
unsigned int numberOfObjects = 0;
myFileInput.seekg(0, std::ios::beg);
myFileInput.read(reinterpret_cast<wchar_t *>(&numberOfObjects), sizeof(unsigned int));
for(int i = 0; i < numberOfObjects; i++)
{
objectStorage.resize(objectStorage.size()+1);
inputArchive>>objectStorage[i];
//myFileInput.read(reinterpret_cast<wchar_t *>(&objectStorage[i])/*(&testReceivedObject)*/, sizeof(testClass));
}
std::cout<<std::endl<<"END."<<std::endl;
}
else
{
std::cout<<"Something has gone disasterously wrong."<<std::endl;
}
myFileInput.close();
for(int i = 0; i < objectStorage.size(); i++)
{
std::wcout<<objectStorage[i].ourString<<std::endl;
}
return 0;
}
错误如下:
1>main.obj : error LNK2019: unresolved external symbol "protected: __thiscall boost::archive::basic_binary_oprimitive<class boost::archive::binary_woarchive,wchar_t,struct std::char_traits<wchar_t> >::~basic_binary_oprimitive<class boost::archive::binary_woarchive,wchar_t,struct std::char_traits<wchar_t> >(void)" (??1?$basic_binary_oprimitive@Vbinary_woarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAE@XZ) referenced in function "public: __thiscall boost::archive::binary_oarchive_impl<class boost::archive::binary_woarchive,wchar_t,struct std::char_traits<wchar_t> >::~binary_oarchive_impl<class boost::archive::binary_woarchive,wchar_t,struct std::char_traits<wchar_t> >(void)" (??1?$binary_oarchive_impl@Vbinary_woarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@QAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol "protected: __thiscall boost::archive::basic_binary_iprimitive<class boost::archive::binary_wiarchive,wchar_t,struct std::char_traits<wchar_t> >::~basic_binary_iprimitive<class boost::archive::binary_wiarchive,wchar_t,struct std::char_traits<wchar_t> >(void)" (??1?$basic_binary_iprimitive@Vbinary_wiarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAE@XZ) referenced in function "public: __thiscall boost::archive::binary_iarchive_impl<class boost::archive::binary_wiarchive,wchar_t,struct std::char_traits<wchar_t> >::~binary_iarchive_impl<class boost::archive::binary_wiarchive,wchar_t,struct std::char_traits<wchar_t> >(void)" (??1?$binary_iarchive_impl@Vbinary_wiarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@QAE@XZ)
1>main.obj : error LNK2019: unresolved external symbol "protected: __thiscall boost::archive::basic_binary_oprimitive<class boost::archive::binary_woarchive,wchar_t,struct std::char_traits<wchar_t> >::basic_binary_oprimitive<class boost::archive::binary_woarchive,wchar_t,struct std::char_traits<wchar_t> >(class std::basic_streambuf<wchar_t,struct std::char_traits<wchar_t> > &,bool)" (??0?$basic_binary_oprimitive@Vbinary_woarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAE@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@_N@Z) referenced in function "protected: __thiscall boost::archive::binary_oarchive_impl<class boost::archive::binary_woarchive,wchar_t,struct std::char_traits<wchar_t> >::binary_oarchive_impl<class boost::archive::binary_woarchive,wchar_t,struct std::char_traits<wchar_t> >(class std::basic_ostream<wchar_t,struct std::char_traits<wchar_t> > &,unsigned int)" (??0?$binary_oarchive_impl@Vbinary_woarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAE@AAV?$basic_ostream@_WU?$char_traits@_W@std@@@std@@I@Z)
1>main.obj : error LNK2019: unresolved external symbol "protected: __thiscall boost::archive::basic_binary_iprimitive<class boost::archive::binary_wiarchive,wchar_t,struct std::char_traits<wchar_t> >::basic_binary_iprimitive<class boost::archive::binary_wiarchive,wchar_t,struct std::char_traits<wchar_t> >(class std::basic_streambuf<wchar_t,struct std::char_traits<wchar_t> > &,bool)" (??0?$basic_binary_iprimitive@Vbinary_wiarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAE@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@_N@Z) referenced in function "protected: __thiscall boost::archive::binary_iarchive_impl<class boost::archive::binary_wiarchive,wchar_t,struct std::char_traits<wchar_t> >::binary_iarchive_impl<class boost::archive::binary_wiarchive,wchar_t,struct std::char_traits<wchar_t> >(class std::basic_istream<wchar_t,struct std::char_traits<wchar_t> > &,unsigned int)" (??0?$binary_iarchive_impl@Vbinary_wiarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAE@AAV?$basic_istream@_WU?$char_traits@_W@std@@@std@@I@Z)
1>main.obj : error LNK2019: unresolved external symbol "protected: void __thiscall boost::archive::basic_binary_oprimitive<class boost::archive::binary_woarchive,wchar_t,struct std::char_traits<wchar_t> >::init(void)" (?init@?$basic_binary_oprimitive@Vbinary_woarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAEXXZ) referenced in function "protected: void __thiscall boost::archive::binary_oarchive_impl<class boost::archive::binary_woarchive,wchar_t,struct std::char_traits<wchar_t> >::init(unsigned int)" (?init@?$binary_oarchive_impl@Vbinary_woarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAEXI@Z)
1>main.obj : error LNK2019: unresolved external symbol "protected: void __thiscall boost::archive::basic_binary_oarchive<class boost::archive::binary_woarchive>::init(void)" (?init@?$basic_binary_oarchive@Vbinary_woarchive@archive@boost@@@archive@boost@@IAEXXZ) referenced in function "protected: void __thiscall boost::archive::binary_oarchive_impl<class boost::archive::binary_woarchive,wchar_t,struct std::char_traits<wchar_t> >::init(unsigned int)" (?init@?$binary_oarchive_impl@Vbinary_woarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAEXI@Z)
1>main.obj : error LNK2019: unresolved external symbol "protected: void __thiscall boost::archive::basic_binary_iprimitive<class boost::archive::binary_wiarchive,wchar_t,struct std::char_traits<wchar_t> >::init(void)" (?init@?$basic_binary_iprimitive@Vbinary_wiarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAEXXZ) referenced in function "protected: void __thiscall boost::archive::binary_iarchive_impl<class boost::archive::binary_wiarchive,wchar_t,struct std::char_traits<wchar_t> >::init(unsigned int)" (?init@?$binary_iarchive_impl@Vbinary_wiarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAEXI@Z)
1>main.obj : error LNK2019: unresolved external symbol "protected: void __thiscall boost::archive::basic_binary_iarchive<class boost::archive::binary_wiarchive>::init(void)" (?init@?$basic_binary_iarchive@Vbinary_wiarchive@archive@boost@@@archive@boost@@IAEXXZ) referenced in function "protected: void __thiscall boost::archive::binary_iarchive_impl<class boost::archive::binary_wiarchive,wchar_t,struct std::char_traits<wchar_t> >::init(unsigned int)" (?init@?$binary_iarchive_impl@Vbinary_wiarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAEXI@Z)
1>main.obj : error LNK2019: unresolved external symbol "protected: void __thiscall boost::archive::basic_binary_iarchive<class boost::archive::binary_wiarchive>::load_override(struct boost::archive::class_name_type &,int)" (?load_override@?$basic_binary_iarchive@Vbinary_wiarchive@archive@boost@@@archive@boost@@IAEXAAUclass_name_type@23@H@Z) referenced in function "protected: void __thiscall boost::archive::binary_iarchive_impl<class boost::archive::binary_wiarchive,wchar_t,struct std::char_traits<wchar_t> >::load_override<struct boost::archive::class_name_type>(struct boost::archive::class_name_type &,int)" (??$load_override@Uclass_name_type@archive@boost@@@?$binary_iarchive_impl@Vbinary_wiarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAEXAAUclass_name_type@12@H@Z)
1>main.obj : error LNK2019: unresolved external symbol "protected: void __thiscall boost::archive::basic_binary_oprimitive<class boost::archive::binary_woarchive,wchar_t,struct std::char_traits<wchar_t> >::save(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?save@?$basic_binary_oprimitive@Vbinary_woarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: static void __cdecl boost::archive::save_access::save_primitive<class boost::archive::binary_woarchive,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(class boost::archive::binary_woarchive &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??$save_primitive@Vbinary_woarchive@archive@boost@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@save_access@archive@boost@@SAXAAVbinary_woarchive@12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "protected: void __thiscall boost::archive::basic_binary_oprimitive<class boost::archive::binary_woarchive,wchar_t,struct std::char_traits<wchar_t> >::save(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" (?save@?$basic_binary_oprimitive@Vbinary_woarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAEXABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z) referenced in function "public: static void __cdecl boost::archive::save_access::save_primitive<class boost::archive::binary_woarchive,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > >(class boost::archive::binary_woarchive &,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const &)" (??$save_primitive@Vbinary_woarchive@archive@boost@@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@save_access@archive@boost@@SAXAAVbinary_woarchive@12@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z)
1>main.obj : error LNK2019: unresolved external symbol "protected: void __thiscall boost::archive::basic_binary_iprimitive<class boost::archive::binary_wiarchive,wchar_t,struct std::char_traits<wchar_t> >::load(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &)" (?load@?$basic_binary_iprimitive@Vbinary_wiarchive@archive@boost@@_WU?$char_traits@_W@std@@@archive@boost@@IAEXAAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z) referenced in function "public: static void __cdecl boost::archive::load_access::load_primitive<class boost::archive::binary_wiarchive,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > >(class boost::archive::binary_wiarchive &,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > &)" (??$load_primitive@Vbinary_wiarchive@archive@boost@@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@load_access@archive@boost@@SAXAAVbinary_wiarchive@12@AAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z)
非常感谢您提供有关了解问题所在以及如何解决问题的建议。
最佳答案
事实证明,boost/archive/binary_woarchive.hpp
和 boost/archive/binary_wiarchive.hpp
是多余的。
相反,boost/archive/binary_oarchive.hpp
和 boost/archive/binary_iarchive.hpp
即使对于包含宽字符变量的类实例也能正常工作!
我希望这些信息对某人有所帮助。
关于c++ - boost/archive/binary_woarchive.hpp 和/或 boost/archive/binary_wiarchive.hpp 的序列化示例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10439984/
有没有办法从 archive.org 上传或触发自己网站的快照到 WayBackMachine?我已经检查了常见问题解答和 archive.org API,但找不到任何使用脚本触发此问题的方法。 最佳
在我当前的项目中,我正在集成 RestKit 库(我不知道它是否重要),当我使用编译器提示的“存档”时尝试交付应用程序进行测试 "RestKit/RestKit.h" is not found 在构
在我的项目开始时,有两个 terraform 模块:base 和 reusable_module。 base/main.tf # Provide abstraction to define a lam
我试图弄清楚如何以正确的方式构建我的 Cocoa 应用程序的发布版本。 到目前为止,我已经使用了 为归档而构建 选项,并从 Xcode 的 DerivedData 文件夹深处获取应用程序包。 今天我试
我有一个 Swift 语言的 iOS 项目,我必须在终端上使用命令创建存档和 .ipa。 我正在使用 Github 操作在试飞中上传 iOS 版本。 我正在遵循此链接中提到的所有说明: https:/
我正在使用 GCC 从两个 *.a(静态库)创建一个共享对象库。我引用了这些文章: How to force gcc to link an unused static library How to i
我的应用程序突然停止创建 iOS App Archive,而是开始创建 Xcode Generic Archive。 这是在为我的应用程序的新版本进行更改后发生的,我添加了逻辑、UI 更改和一些新框架
我有一个包含大约 800 个 .tgz 文件的目录,每个文件包含大约 10 个文件。实际上,我想将每个存档转换为同名目录。是否有一个简单的一行命令来执行此操作,还是我应该编写一个脚本? 最佳答案 自
在 gcc 中使用 -Wl--whole-archive ... -Wl--no-whole-archive 标志时,您如何验证库内部的所有内容都正确链接?另外,您如何验证该库是否可以调用由 LD_L
我有一个用 Swift 编写的小型命令行应用程序,现在我想将其归档。然而,像我之前的许多其他人一样,我遇到了如何将 Archive Type 从 Generic Xcode Archive 更改为 M
我不确定是否应该对 .emacs.d 下的以下文件进行版本控制: [lucas@lucas-ThinkPad-W520]/home/lucas/.emacs.d$ file elpa/archives
我正在处理 Postgres DVD tutorial并且在导入示例数据库时遇到问题。 运行 pg_restore -U postgres -d dvdrental ~[filepath]/dvd-d
注意: Boost 的存档方案基于对称的输入和输出存档类。一直写这两者很乏味,所以我将使用 ?archive 来表示 oarchive 和 iarchive。 总结: 将自定义存档的基类从 binar
是否可以使用 Node.js 流构建一个 zip 存档,并在创建时通过对 HTTP GET 请求的响应将该 zip 存档提供给客户端/用户?我正在寻找一种最好避免将整个 zip 缓冲到服务器内存中的解
我正在尝试使用 XCODE 4.3.1 发布一个临时 ipa。归档我的 iOS 应用程序时,我可以在管理器中看到归档类型是“Mac App Archive”,虽然我知道它应该是“iOS App Arc
我正在参加 Udacity 的类(class),该类(class)要求我在我的系统上设置虚拟机。我已经下载并安装了 Virtual Box 和 Vagrant。当我尝试运行命令 vagrant up
我试图找到一个很好的例子来说明如何使用这些二进制宽字符版本的 boost 序列化内容。我拼凑了一些代码来尝试让它工作,但不幸的是,我在尝试编译它时遇到了链接器错误的轰炸。 这是我的代码,以防我做任何明
目标与问题 我在 IntelliJ 中创建了一个 Java 程序。我按照说明将其构建为 .jar 文件 here 。当我尝试运行它时,它给出以下输出: Parameters: archive-name
我已包含在 hector-core-1.1-2 文件夹中找到的所有 jar。还有其他我没有包含的 jar 吗?我尝试过的事情。1)清除netbeans缓存2)下载org.apache.xbean.fi
我正在尝试打开包含创建数据库和 INSERT 语句的 PostgreSQL 的 SQL 脚本(.sql 文件),但是当我尝试使用 PgAdmin 4 恢复数据库时,它给我错误提示“pg_restore
我是一名优秀的程序员,十分优秀!