Search code examples
c++booststatic-linkingdynamic-linking

How does boost link libs?


As I understand I must link additional libraries or not using boost and it depends on some modules require them or they are just independent templates/macros.

For instance using boost/thread.hpp I must link boost_thread and boost_system.

  1. So if I link them dynamically I need to have boost on target platform or just add them to the final application (same or not directory)?

2.If I don't want any dependencies I can link them statically, however the size of the application will grow by size of whole library or just by part of it I've used?


Solution

  • Q1. Yes or no. If you're in Windows, the shared library (.dll) can be in system directory or local directory (which the program is). If you're in linux, the shared library (.so) must be in LD_LIBRARY_PATH.

    Q2. No, the program's size doesn't grow by size of whole library. If your linker isn't crazy, he will select necessary object of library and link the program against only them.