简体   繁体   English

当我使用“boost :: log :: add_file_log()”函数时,“error ld返回1退出状态”

[英]“error ld returned 1 exit status” when i use “boost::log::add_file_log()” function

The code: 编码:

#include <boost/log/support/date_time.hpp>
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks/text_file_backend.hpp>
#include <boost/log/utility/setup/file.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/sources/record_ostream.hpp>


int main()
{
    boost::log::add_file_log(
       boost::log::keywords::auto_flush = true,
       boost::log::keywords::file_name = "log%Y-%m-%d_%H-%M-%S.%N.log",
       boost::log::keywords::rotation_size = 10 * 1024 * 1024,

       /*if delete here, the compiler was successful*/
       boost::log::keywords::format  = "[%TimeStamp%] (%Severity%) : %Message%",
       boost::log::keywords::min_free_space=3 * 1024 * 1024
       );
}

I try compile this code,but prompt information:“error ld returned 1 exit status”. 我尝试编译此代码,但提示信息:“错误ld返回1退出状态”。

if I delete boost::log::keywords::format = "[%TimeStamp%] (%Severity%) : %Message%", this code can be compiled successfully. 如果我删除boost::log::keywords::format = "[%TimeStamp%] (%Severity%) : %Message%",则可以成功编译此代码。

您需要构建并链接Boost日志库才能使此代码生效,请参阅http://www.boost.org/doc/libs/1_62_0/libs/log/doc/html/log/installation/config.html

When I add -lboost_log_setup and rebuild the project, this problem is resolved. 当我添加-lboost_log_setup并重建项目时,此问题已得到解决。

So,it should be link -lboost_system -lboost_thread -lboost_log -lpthread -lboost_log_setup 所以,它应该是链接-lboost_system -lboost_thread -lboost_log -lpthread -lboost_log_setup

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM