C++提升日志记录编译错误 (Linux)
C++ boost logging compile error (linux)
谁能告诉我我做错了什么?
在控制台上运行此操作会产生以下错误:
#
c++ -I/var/local/boost_1_46_1/log.cpp -o log -lboost-log
log.cpp: 在函数中 'void init()â: log.cpp:11:错误:"提升::日志记录"尚未声明 log.cpp:13:错误:尚未声明"提升::FLT" 日志.cpp:13:错误:"日志记录"尚未声明 日志.cpp:13:错误:"日志记录"尚未声明
我也尝试过从 stage 和/usr/local/lib 目录显式链接库。
我的日志.cpp:
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/filters.hpp>
using namespace std;
void init()
{
boost::logging::core::get()->set_filter
(
boost::flt::attr< boost::logging::trivial::severity_level >("Severity") >= boost::logging::trivial::info
);
}
}
int main(int, char*[]) {
BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
BOOST_LOG_TRIVIAL(info) << "An informational severity message";
BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
BOOST_LOG_TRIVIAL(error) << "An error severity message";
BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
}
如果我省略void init()
函数,这段代码将编译......
需要以下命名空间重定义才能使用这些教程:
namespace logging = boost::log;
namespace sinks = boost::log::sinks;
namespace src = boost::log::sources;
namespace fmt = boost::log::formatters;
namespace flt = boost::log::filters;
namespace attrs = boost::log::attributes;
namespace keywords = boost::log::keywords;
http://boost-log.sourceforge.net/libs/log/doc/html/log/how_to_read.html
你确定你的#include
是正确的吗?试试#include <boost/log/core/core.hpp>
。
相关文章:
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- 这些是什么样的错误?即使我不在 Linux 上工作,我也遇到了 Linux 错误
- Arch Linux.AUR 包 mysql 不能用 makepkg 构建.错误:构建 () 中出现故障
- 分段 Linux Ubuntu 中的 g++ 错误,但在 Windows 中的 g++/MingW 中,在 C++ 中打
- [longjmp/setjmp]c++ 相同的代码窗口有异常 Linux 没有错误并且运行良好
- 在 Linux 中使用 -fvisibility=hidden 编译时出现库加载错误
- g++ 9.2.1 (Linux) 会导致 seg 错误,但 Windows 上的代码块不会
- 调试模板时出现问题.专门针对 Linux GCC 7、GCC 6、GCC 5、GCC 4.9 错误构建失败:模板参数 1
- LINUX 操作系统上的错误:令牌之前预期的构造函数、析构函数或类型转换'('?
- 从 Linux OMI (omicli) 到 Windows WMI 的连接失败,并出现与 DMTF 相关的错误
- C++ Linux 运行时basic_string::_M_construct null 无效错误
- Stringstream编译错误仅发生在linux环境中
- 如何在长g++错误消息上使用linux less命令
- curl_easy_在Linux上执行分段错误
- 在linux上使用g++输出错误,在windows上更正
- C++新手,得到编译错误(Linux,G ++编译器)
- Android NDK示例构建错误linux
- 共享内存的std::string给分割错误(linux)
- c++ Sockets -客户端给出分段错误(linux)
- C++提升日志记录编译错误 (Linux)