【发布时间】:2015-11-23 11:54:03
【问题描述】:
我有两个简单的应用程序,它们使用来自boost_1_55_0 的共享内存。BoostCreate.exe 创建共享内存。BoostOpen.exe 打开创建的共享内存。
我用 VS2008 和它们在 Windows7/8.1 上工作,但在 Windows XP 上BoostOpen.exe 无法打开共享内存。
这是BoostCreate.exe 代码:
using namespace boost::interprocess;
std::string shMemName("MySharedMem");
managed_shared_memory shMem = managed_shared_memory(create_only, shMemName.c_str(), 1000);
这是BoostOpen.exe 代码:
using namespace boost::interprocess;
std::string shMemName("MySharedMem");
try
{
managed_shared_memory shMem = managed_shared_memory(open_only, shMemName.c_str());
}
catch(boost::interprocess::interprocess_exception& e)
{
printf("Error opening %s\n", e.what());
}
例外是:The system cannot find the file specified。
尝试boost_1_59_0 我得到一些链接器错误:
error LNK2001: unresolved external symbol "public: void __thiscall boost::container::container_detail::has_member_function_named_construct<class boost::container::new_allocator<char> >::BaseMixin::construct(void)" (?construct@BaseMixin@?$has_member_function_named_construct@V?$new_allocator@D@container@boost@@@container_detail@container@boost@@QAEXXZ)
【问题讨论】:
-
链接器错误可以通过构建调试版本或禁用优化来解决,它出现了。试试看 Boost 1_59 上的行为是什么
-
您是否在同一个session 中运行客户端?权限和命名空间可能导致地图不可见/不可访问
-
是的,使用本机 Win32
CreateFileMapping和OpenFileMapping,我可以创建和打开相同的共享内存。不幸的是,我在这里使用managed_shared_memory;;construct<T>,并且需要重写大量代码才能使用本机 API。 -
与
Boost 1_55和Boost 1_59的结果相同 -
你能追溯到哪些 Win32 API 失败了吗?