Having problems compiling an example in the boost Logging Tutorial

25 Views Asked by At

I am having a problem building the following code from the boost tutorial. Here is the link to the boost tutorial and example code: https://boost-log.sourceforge.net/libs/log/doc/html/log/tutorial/formatters.html

void init()
{
    logging::add_file_log
    (
        keywords::file_name = "sample_%N.log",
        keywords::rotation_size = 10 * 1024 * 1024,
        keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0),
        keywords::format = "[%TimeStamp%]: %Message%"
    );

    logging::core::get()->set_filter
    (
        logging::trivial::severity >= logging::trivial::info
    );
}

Here is the build error

/local/include/boost/log/utility/setup/formatter_parser.hpp:207: undefined reference to `boost::log::v2s_mt_posix::basic_formatter<char> boost::log::v2s_mt_posix::parse_formatter<char>(char const*, char const*)'
collect2: error: ld returned 1 exit status

If I comment out the the following line from the code above it will build fine.

keywords::format = "[%TimeStamp%]: %Message%" 

So it appears to be something on that particular line that is causing the build failure.

I also added the following include I found in another posting on this site. This did not help either.

Compilation error with Boost log library when using date_time_formatter

#include <boost/log/support/date_time.hpp>
0

There are 0 best solutions below