#include < boost/chrono.hpp> 导致未解析的外部符号,使用 bcp

#include <boost/chrono.hpp> causes unresolved external symbol, bcp used

本文关键字:外部 bcp 使用 符号 boost lt chrono hpp #include gt      更新时间:2023-10-16

我不是一个经验丰富的程序员。我尝试将boost的一部分剪切并直接粘贴到我的项目中,该项目是Visual Studio 2010中的C++解决方案。我是这样做的:

  • 解压缩boost库
  • bootstrap.bat
  • bjam tools/bcd-这创建了目录。\bin.v2\tools\bcp\msvc-10.0\release\link static\threading multi\
  • 将目录更改为上述内容
  • 我已经编写了一个扫描解决方案中所有文件的脚本,结果是:
    不可复制的static_assert比率线程/锁定线程chrono interprocess/mapped_region线程/recursive_mutex crc cstilt interprocess/file_mapping make_shared shared_ptr lexical_cast
  • bcp --boost=C:Usersxxxxxxxxboost_1_49_0 noncopyable static_assert ratio thread/locks thread chrono interprocess/mapped_region thread/recursive_mutex crc cstdint interprocess/file_mapping make_shared shared_ptr lexical_cast lexical_cast ./myboost
  • 复制/myboost到解决方案中,设置属性,一切都很好,直到我不尝试#include"boost/chrono.hpp"(例如#include"boost/lixical_cast.hpp"可以)
  • boost/cochrono.hpp导致链接器错误:

    3> playerMain.obj:error LNK2001:未解析的外部符号"class boost::system::error_category const&__cdecl boost:;system::system_categor(void)"(?system_category@system@助推@@YAABVerror_category@12@XZ)

    3> playerMain.obj:error LNK2001:未解析的外部符号"class boost::system::error_category const&__cdecl boost:;system::general_category(void)"(?generic_category@system@助推@@YAABVerror_category@12@XZ)


我正确使用bcp吗
我该怎么做才能让它发挥作用?

这里非常清楚地说明了安装Boost以便与Visual Studio一起使用的过程。您不需要编写任何安装脚本。

重要的是要知道,大多数Boost库都只是头库(如Boost.Lexical_Cast),但有些库需要链接到静态库(如Boost.System)。请参阅入门文档的这一部分,了解如何让Visual Studio知道Boost静态库在哪里。

本节仅列出哪些库是而不是标头。有些库(如Boost.Cchrono和Boost.Asio)本身只是头,但它们依赖于需要链接到程序中的Boost.System

希望这能有所帮助。