Customize Builds to Reduce Dependencies
There are many libraries that provide macros or configuration options to remove optional components and so reduce dependencies. Refer to the documentation, in particular the macros, for the individual libraries you intend to use. Here are some specific examples:
Boost.Asio
Boost.Asio defines macros to remove certain functionality and control behavior:
-
BOOST_ASIO_SEPARATE_COMPILATIONuse the header-only features of the library. -
BOOST_ASIO_DISABLE_SSLdisables timers and SSL components.
Boost.Filesystem
Boost.Filesystem includes macros to control its behavior and reduce dependencies. For example:
-
BOOST_FILESYSTEM_NO_DEPRECATEDdisables deprecated features. -
BOOST_FILESYSTEM_NO_LIBprevents automatic linking of the library.
Boost.Locale
Boost.Locale allows customization through macros:
-
BOOST_LOCALE_WITH_ICUenables or disables ICU support. -
BOOST_LOCALE_WITH_ICONVenables or disables Iconv support. -
BOOST_LOCALE_WITH_STDenables or disables support for the standard library’s localization facilities.
Boost.Log
Boost.Log has optional features that can be disabled using macros, such as:
-
BOOST_LOG_NO_THREADSdisables multi-threading support if not required. -
BOOST_LOG_WITHOUT_DEBUG_OUTPUTremoves debug output support. -
BOOST_LOG_WITHOUT_EVENT_LOGexcludes Windows Event Log support. -
BOOST_LOG_WITHOUT_SYSLOGdisables support for Syslog (on Unix systems).
Boost.ProgramOptions
Boost.ProgramOptions provides macros to remove certain components:
-
BOOST_PROGRAM_OPTIONS_NO_LIBdisables automatic linking.
It also allows customization to minimize dependencies when certain features aren’t needed, such as avoiding wide-character support. Refer to its documentation.
Boost.Python
Boost.Python has options to exclude optional components, such as disabling support for certain Python features or optimizations:
BOOST_PYTHON_NO_LIB disables automatic linking.
Boost.Regex
Boost.Regex offers macros to customize its functionality, such as:
-
BOOST_REGEX_NO_LIBdisables automatic linking. -
BOOST_REGEX_NO_EXTERNAL_TEMPLATESprevents the use of external templates to reduce dependencies. -
BOOST_REGEX_MATCH_EXTRAcan be undefined to exclude certain match-related features.
Boost.Serialization
Boost.Serialization allows disabling certain features to reduce dependencies:
-
BOOST_SERIALIZATION_NO_LIBdisables automatic linking. -
BOOST_SERIALIZATION_NO_XML_ARCHIVEexcludes XML archive support. -
BOOST_SERIALIZATION_NO_TEXT_ARCHIVEexcludes text archive support. -
BOOST_SERIALIZATION_NO_EXCEPTION_SAFETYremoves exception safety-related functionality.
Boost.System
Boost.System has macros to control its behavior:
-
BOOST_ERROR_CODE_HEADER_ONLYmakes it header-only by eliminating the need for compiled binaries.
Boost.Test
Boost.Test allows stripping optional components to make it more lightweight:
-
BOOST_TEST_NO_LIBdisables automatic linking. -
BOOST_TEST_DYN_LINKforces dynamic linking. -
BOOST_TEST_NO_MAINprevents the inclusion of the main function, allowing integration into existing test frameworks.