使用 Boost Interprocess 1.60 发布版本时出现奇怪的链接器错误

Strange linker error when using Boost Interprocess 1.60 release build

我们有一些代码使用 Boost Interprocess 来管理共享内存。它可以很好地链接到我们的 Boost 1.60 调试版本,也可以链接到我们的 Boost 1.55 发布版本,但是当链接到我们的 Boost 1.60 发布版本时,我得到以下两个错误:

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_at_BaseMixin@?$has_member_function_named_construct_at_V?$new_allocator_at_D@container_at_boost@@@container_detail_at_container@boost@@QAEXXZ)

error LNK2001: unresolved external symbol "public: void __thiscall boost::container::container_detail::has_member_function_named_construct<class boost::container::new_allocator<struct boost::container::container_detail::tree_node<struct std::pair<class boost::container::basic_string<char,struct std::char_traits<char>,class boost::container::new_allocator<char> > const ,struct boost::interprocess::ipcdetail::ref_count_ptr>,void *,0,1> > >::BaseMixin::construct(void)" (?construct_at_BaseMixin@?$has_member_function_named_construct_at_V?$new_allocator_at_U?$tree_node_at_U?$pair@$$CBV?$basic_string_at_DU?$char_traits_at_D@std@@V?$new_allocator_at_D@container_at_boost@@@container_at_boost@@Uref_count_ptr_at_ipcdetail@interprocess_at_3@@std@@PAX[=11=]A@[=11=]_at_container_detail_at_container@boost@@@container_at_boost@@@container_detail_at_container@boost@@QAEXXZ)

谷歌搜索我发现 this 关于 Boost 邮件列表的报告,但那里没有解决方案。

编译器是Visual Studio2010,库是Boost自动引入的。

这似乎与项目文件中的预编译头配置有关。在我的例子中,我可以将选项设置为不使用预编译头文件并且它工作正常。 这里有一个线程可以详细了解它 here