How to link Boost in a dependent static library

前端 未结 3 1865
野趣味
野趣味 2020-12-08 15:28

In MS Visual C++ 2010

I had a single C++ project in my solution which used boost and worked perfectly.

I then decided to convert this project into a static

相关标签:
3条回答
  • 2020-12-08 15:53

    Did you build boost library? There are certain libraries in Boost that needs to be compiled. In case if you haven't done that, refer to "Getting started in Windows" on how to build the Boost library.

    EDIT-1: Boost can be built both as a static and dynamically loadable (dll) libraries.

    EDIT-2: If you have already built Boost, then the answer by @Daniel Gehriger tells you how to add it in VS.

    0 讨论(0)
  • 2020-12-08 15:57

    Apparently you don't need the .libs, as your exe also links without them. You seem to be using boost header-only methods and classes. So just tell boost to disable auto linking by defining the preprocessor symbol BOOST_ALL_NO_LIB in your project.

    If you want to make your .lib unnecessary big by including all of boost, this question seems to hold an answer (which I never really tried myself): Linking static libraries to other static libraries

    0 讨论(0)
  • 2020-12-08 16:00

    When building your library, you can include the boost libraries in yours. To do so, in VisualStudio's Librarian > General property page, list your boost libraries as Additional Dependencies.

    However, there may be a problem if your clients use boost themselves, and statically link to it (especially a different version than the one you are using).

    0 讨论(0)
提交回复
热议问题