Trying to build the next program which use Boost::library and trying to create a new logger:
#include <string>
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
class TestClass
{
...
boost::log::sources::logger lg;
};
My Cmake file for building this file:
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.63.0
COMPONENTS system
filesystem
log
log_setup
thread
unit_test_framework
REQUIRED)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
file(GLOB PROJECT_SOURCES sources/*.cpp
sources/configuration/*.cpp)
file(GLOB PROJECT_HEADERS sources/*.h
sources/configuration/*.h)
add_executable(${PROJECT_NAME}
${PROJECT_SOURCES}
${PROJECT_HEADERS})
target_link_libraries(${PROJECT_NAME}
${Boost_LIBRARIES}
Boost::log)
But during linking I get the next error:
error: 'logger' in namespace 'boost::log::v2_mt_nt5::sources' does not name a type
boost::log::sources::logger log;
Why my namespace boost::log::sources
is converted to boost::log::v2_mt_nt5::sources
? How to solve this issue?
You are simply missing an include directive:
#include <boost/log/sources/logger.hpp>