誰能告訴我我做錯了什麼?C++ boost日誌編譯錯誤(linux)
在控制檯上運行此產生以下錯誤:
#
c++ -I /var/local/boost_1_46_1/ log.cpp -o log -lboost-log
log.cpp: In function âvoid init()â: log.cpp:11: error: âboost::loggingâ has not been declared log.cpp:13: error: âboost::fltâ has not been declared log.cpp:13: error: âloggingâ has not been declared log.cpp:13: error: âloggingâ has not been declared
我也試過它明確地從兩個階段鏈接庫和/ usr/local/lib目錄的目錄。
我log.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()
功能這個代碼將編譯...
我仍然收到錯誤,我將使用我所做的更改更新原始帖子。 – suhprano 2011-05-19 19:13:56
我的不好,教程重新定義了命名空間。我會編輯我的答案。 – 2011-05-19 19:22:36
真棒,感謝您的幫助。 – suhprano 2011-05-19 19:32:47