簡體   English   中英

當我使用“boost :: log :: add_file_log()”函數時,“error ld返回1退出狀態”

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

編碼:

#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
       );
}

我嘗試編譯此代碼,但提示信息:“錯誤ld返回1退出狀態”。

如果我刪除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

當我添加-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