In this example, we're demonstrating how to log to the console using boost's trivial logging APIs, as follows:
#include <boost/log/trivial.hpp>
int main(void)
{
BOOST_LOG_TRIVIAL(debug) << "debug message";
BOOST_LOG_TRIVIAL(info) << "info message";
return 0;
}
As shown in the preceding example, the "debug message" and "info message" messages were outputted to stdout. In addition to linking against the proper boost libraries, we also had to include the following definition during compilation:
-DBOOST_LOG_DYN_LINK -lboost_log -lboost_system -lpthread
Once again, linking these libraries ensures that the APIs you are using in your code (as shown in the preceding example) exist in the executable.