简体   繁体   中英

Why do I still have to use BOOST_LOG_DYN_LINK or BOOST_ALL_DYN_LINK on linux when compiling with boost?

AFAIK, these two macros are used to enable auto_link.hpp to generate #pragma comment(lib, name) so that the linker can automatically link the used libraries, which should only works on windows. But on linux, why do I still need to define at least one of the two macros, while the used libraries must also be specified? Or how do these two macros work on linux?

The macros:

  • BOOST_LOG_DYN_LINK
  • BOOST_TEST_DYN_LINK
  • BOOST_ALL_DYN_LINK
  • etc

indicate that the code will be linked against a dynamically loaded ( so or dll ) boost library.

Since boost libraries on linux are normally built as dynamically loaded libraries it is necessary to define one of the macros above to link the relevant boost libraries.

Boost libraries on Windows are normally built as statically linked libraries. However, if the relevant boost libraries have been built as dynamically loaded libraries then the macros are also required when building on Windows .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM