地图在共享内存:Boost.Interprocess中演示失败,因为未满足的依赖DATE_TIME [英] maps in shared memory: Boost.Interprocess demo fails due to unmet date_time dependency
问题描述
我要创建共享地图
对象多个进程可以访问。最有希望的方法,我发现是<一个href=\"http://www.boost.org/doc/libs/1_57_0/doc/html/interprocess/allocators_containers.html#interprocess.allocators_containers.containers_explained.containers_of_containers\"相对=nofollow>从Boost.Interprocess中,该分配地图
对象在托管共享内存段这个演示code。这个问题将主要是对我有升压问题,但我也很感激,如果任何人有非增压替代方法。
我完全新的提升:它看起来令人惊讶,如果巨大的,而我也被其主张鼓励的时候,没有什么建设。但是,在这种情况下,这一承诺在什么似乎是一场毫无意义的方式打破了,我不能编译,因为内部的提振依赖问题的演示。
我在Windows上,与安装Visual C ++防爆preSS 2010
:保存演示code作为 shmap.cpp
我后执行下列操作 %VS100COMNTOOLS%\\ .. \\ .. \\ VC \\ vcvarsall.bat
CL / EHSC / I boost_1_57_0 shmap.cpp
它编译OK,但后来我得到这样的:
LINK:致命错误LNK1104:无法打开文件'libboost_date_time-VC100-MT-S-1_57.lib
这让我惊讶的多个层面。 (Q1):我没有问图书馆---在何处以及如何提高领导的链接期望他们? (Q2):为什么会特别被要求 DATE_TIME
?同时在code无点是什么,在功能上具体的日期或时间计算,引用或包含在内。这是过分热心毯子依赖的情况下,如果是这样,有没有办法,我可以杂草出来?
无论如何,要尽量显而易见的第一件事就是玩的游戏:在我跑了 boost_1_57_0
目录 bootstrap.bat
其次 B2
。地球翻了好几度,升压成功建成,我重新尝试:
CL / EHSC / I boost_1_57_0 shmap.cpp /链接/ LIBPATH:boost_1_57_0 \\阶段\\ lib中
我仍然得到同样的连接错误。这是因为 B2
似乎已经与 -mt库 -
和 -mt- GD -
在自己的名字,而与 -mt-S -
链接器所期待的。 Boost的入门网页告诉我一下这些代表,但并没有告诉我的(Q3):我怎样才能改变,要么被建成了图书馆的类型,或者链接器所需的类型?
在在code无点是什么,在功能上具体的计算日期或时间,引用或包含在内。
(Q2):为什么会被要求DATE_TIME尤其
块引用>显然,你所用的东西依赖于它。
例如互斥操作有 <一个href=\"http://www.boost.org/doc/libs/1_57_0/doc/html/interprocess/synchronization_mechanisms.html#interprocess.synchronization_mechanisms.mutexes.mutexes_mutex_operations\"相对=nofollow>
timed_lock
功能
(Q1):我没加库项目---在哪里以及如何提高是导致连接器的期望呢?
块引用>升压(默认设置)autolinking。它使用MSVC ++编译指示的具体指示正确的链接库右侧的味道。这是一个真棒功能。
您只需要确保导入库是为您的项目库路径上。
有很多方法可以禁用自动升压联(我认为这涉及定义BOOST_ALL_NO_LIB)
有可能的某些方法来
- 禁用升压DATE_TIME依赖(惊叹的功能);看到在 autl链接描述入门指南
- 链接到DATE_TIME静态(或使其头只)
我会参考这方面的文档。
I want to create shared
map
objects that multiple processes can access. The most promising approach I've found is this demo code from Boost.Interprocess, which allocatesmap
objects in a managed shared memory segment. This question will mostly be about the boost problems I'm having, but I'd also be grateful if anyone has non-boost alternative approaches.I'm completely new to boost: it looks amazing, if huge, and I was encouraged by its claim that "often, there's nothing to build". But in this case that promise is broken in what seems to be a senseless way, and I'm failing to compile the demo because of dependency problems internal to boost.
I'm on Windows, with Visual C++ Express 2010 installed. After saving the demo code as
shmap.cpp
I do the following:"%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" cl /EHsc /I boost_1_57_0 shmap.cpp
It compiles OK, but then I get this:
LINK : fatal error LNK1104: cannot open file 'libboost_date_time-vc100-mt-s-1_57.lib'
This surprises me on a number of levels. (Q1): I didn't ask for libraries---where and how is boost leading the linker to expect them? (Q2): Why would it be asking for
date_time
in particular? At no point in the code is anything as functionally specific as a date or time computed, referenced or included. Is this a case of overzealous blanket dependency, and if so is there a way I can weed it out?Regardless, the obvious first thing to try was to play the game: in the
boost_1_57_0
directory I ranbootstrap.bat
followed byb2
. The Earth turned a good few degrees, boost was built successfully, and I retried with:cl /EHsc /I boost_1_57_0 shmap.cpp /link /LIBPATH:boost_1_57_0\stage\lib
I still get the same linker error. This is because
b2
seems to have built libs with-mt-
and with-mt-gd-
in their names, but not with the-mt-s-
that the linker is looking for. Boost's "Getting Started" webpage tells me what these stand for but doesn't tell me (Q3): how can I change either the type of library that gets built, or the type that the linker expects?解决方案"At no point in the code is anything as functionally specific as a date or time computed, referenced or included."
(Q2): Why would it be asking for date_time in particular?
Apparently the things you used depend on it.
E.g the mutex operations have
timed_lock
function(Q1): I didn't add libraries to the project---where and how is boost leading the linker to expect them?
Boost does autolinking by default. This uses MSVC++ specific pragmas to indicate the right flavour of the right link libraries. This is an awesome feature.
You just have to make sure the import libraries are on the library path for your project.
There are ways to disable auto-linking in boost (I think it involves defining BOOST_ALL_NO_LIB)
There might be ways to
- disable dependency on boost date_time (dropping features); see the autl-link description in the Getting Started guide
- linking to date_Time statically (or make it header-only)
I'd refer to the documentation for this.
这篇关于地图在共享内存:Boost.Interprocess中演示失败,因为未满足的依赖DATE_TIME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!