Linking with a library that defines the missing symbol (-lboost_system
) is the obvious solution, but in the particular case of Boost.System, a misfeature in the original design makes it use boost::system::generic_category()
and boost::system::system_category()
needlessly. Compiling with the flag -DBOOST_SYSTEM_NO_DEPRECATED
disables that code and lets a number of programs compile without requiring -lboost_system
(that link is of course still needed if you explicitly use some of the library's features).
Starting from Boost 1.66 and this commit, this behavior is now the default, so hopefully fewer and fewer users should need this answer.
As noticed by @AndrewMarshall, an alternative is to define BOOST_ERROR_CODE_HEADER_ONLY
which enables a header-only version of the code. This was discouraged by Boost as it can break some functionality. However, since 1.69, header-only seems to have become the default, supposedly making this question obsolete.