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_COMPILATION use the header-only features of the library.

  • BOOST_ASIO_DISABLE_SSL disables timers and SSL components.

Boost.Filesystem

Boost.Filesystem includes macros to control its behavior and reduce dependencies. For example:

  • BOOST_FILESYSTEM_NO_DEPRECATED disables deprecated features.

  • BOOST_FILESYSTEM_NO_LIB prevents automatic linking of the library.

Boost.Locale

Boost.Locale allows customization through macros:

  • BOOST_LOCALE_WITH_ICU enables or disables ICU support.

  • BOOST_LOCALE_WITH_ICONV enables or disables Iconv support.

  • BOOST_LOCALE_WITH_STD enables 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_THREADS disables multi-threading support if not required.

  • BOOST_LOG_WITHOUT_DEBUG_OUTPUT removes debug output support.

  • BOOST_LOG_WITHOUT_EVENT_LOG excludes Windows Event Log support.

  • BOOST_LOG_WITHOUT_SYSLOG disables support for Syslog (on Unix systems).

Boost.ProgramOptions

Boost.ProgramOptions provides macros to remove certain components:

  • BOOST_PROGRAM_OPTIONS_NO_LIB disables 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_LIB disables automatic linking.

  • BOOST_REGEX_NO_EXTERNAL_TEMPLATES prevents the use of external templates to reduce dependencies.

  • BOOST_REGEX_MATCH_EXTRA can be undefined to exclude certain match-related features.

Boost.Serialization

Boost.Serialization allows disabling certain features to reduce dependencies:

  • BOOST_SERIALIZATION_NO_LIB disables automatic linking.

  • BOOST_SERIALIZATION_NO_XML_ARCHIVE excludes XML archive support.

  • BOOST_SERIALIZATION_NO_TEXT_ARCHIVE excludes text archive support.

  • BOOST_SERIALIZATION_NO_EXCEPTION_SAFETY removes exception safety-related functionality.

Boost.System

Boost.System has macros to control its behavior:

  • BOOST_ERROR_CODE_HEADER_ONLY makes 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_LIB disables automatic linking.

  • BOOST_TEST_DYN_LINK forces dynamic linking.

  • BOOST_TEST_NO_MAIN prevents the inclusion of the main function, allowing integration into existing test frameworks.