Question

I'm not an experienced programmer. I tried to cut part of boost and paste it directly into my project which is a C++ solution in Visual Studio 2010. I've done it this way:

  • uncompress boost library
  • bootstrap.bat
  • bjam tools/bcd - this created dir .\bin.v2\tools\bcp\msvc-10.0\release\link-static\threading-multi\
  • change dir to mentioned above
  • i've written a script for scanning all files in the solution, the result is:
    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
  • copy ./myboost into solution, set up properties, everything works fine until I'm not trying to #include "boost/chrono.hpp" (e.g. #include "boost/lexical_cast.hpp" is ok).
  • boost/chrono.hpp causes linker error:

    3>playerMain.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category@system@boost@@YAABVerror_category@12@XZ)

    3>playerMain.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category@system@boost@@YAABVerror_category@12@XZ)


Do I use bcp correctly?
What should I do to make it work?

Was it helpful?

Solution

The process for installing Boost for use with Visual Studio is spelled out fairly clearly here. You shouldn't need to write any installation scripts.

It's important to know that most Boost libraries are header-only (such as Boost.Lexical_Cast), yet some require you to link to a static library (such as Boost.System). See this section of the Getting Started document on how to let Visual Studio know where the Boost static libraries are.

This section lists which libraries are not header-only. Some libraries (such as Boost.Chrono and Boost.Asio) are themselves header-only, but they depend on Boost.System which needs to be linked into your program.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top