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

时间:2012-03-10 21:57:30

标签: c++ visual-studio boost linker-errors lnk2001

我不是一位经验丰富的程序员。 我试图削减部分boost并将其直接粘贴到我的项目中,这是Visual Studio 2010中的C ++解决方案。 我这样做了:

  • 解压缩升级库
  • bootstrap.bat
  • bjam tools/bcd - 创建了dir 。\ bin.v2 \ tools \ bcp \ msvc-10.0 \ release \ link-static \ threading-multi \
  • 将dir改为上述
  • 我写了一个用于扫描解决方案中所有文件的脚本,结果是:
    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
  • bcp --boost=C:\Users\xxxxxxxx\boost_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 / lexical_cast.hpp “没关系。”
  • boost / chrono.hpp导致链接器错误:

    3&gt; playerMain.obj:错误LNK2001:未解析的外部符号“class boost :: system :: error_category const&amp; __cdecl boost :: system :: system_category(void)”(?system_category @ system @ boost @@ YAABVerror_category @ 12 @ XZ)

    3&gt; playerMain.obj:错误LNK2001:未解析的外部符号“class boost :: system :: error_category const&amp; __cdecl boost :: system :: generic_category(void)”(?generic_category @ system @ boost @@ YAABVerror_category @ 12 @ XZ)


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

1 个答案:

答案 0 :(得分:3)

安装Boost以便与Visual Studio一起使用的过程相当清楚here。您不需要编写任何安装脚本。

重要的是要知道大多数Boost库只是标头(例如Boost.Lexical_Cast),但有些需要您链接到静态库(例如Boost.System)。请参阅“入门”文档中的section,了解如何让Visual Studio知道Boost静态库的位置。

section列出哪些库仅限标题。一些库(例如Boost.Chrono和Boost.Asio)本身只是标题,但它们依赖于需要链接到程序中的Boost.System

希望这有帮助。