C++ Can';t在OS X上编译Boost.log
我正在尝试构建并运行C++ Can';t在OS X上编译Boost.log,c++,logging,boost,xcode4,C++,Logging,Boost,Xcode4,我正在尝试构建并运行Boost.log的教程示例,并得到一个编译器错误,这让我很困惑,需要一些帮助。基本细节;我已经在OS X上构建了boost,包含了boost.log,但是当我试图编译任何教程示例时,我从boost日志的'trial.hpp'包含文件中得到了一个重载的'operator>'错误 据报告,这些错误位于中 log/utility/explicit\u operator\u bool.hpp 这是堆栈: /usr/local/include/boost/log/utility/ex
Boost.log
的教程示例,并得到一个编译器错误,这让我很困惑,需要一些帮助。基本细节;我已经在OS X上构建了boost,包含了boost.log
,但是当我试图编译任何教程示例时,我从boost日志的'trial.hpp'
包含文件中得到了一个重载的'operator>'
错误
据报告,这些错误位于中
log/utility/explicit\u operator\u bool.hpp
这是堆栈:
/usr/local/include/boost/log/utility/explicit_operator_bool.hpp:67:29: error: overloaded 'operator>>' must have at least one parameter of class or enumeration type [2]
In file included from /usr/local/include/boost/log/attributes/attribute_name.hpp:27:
In file included from /usr/local/include/boost/log/attributes/attribute_set.hpp:28:
In file included from /usr/local/include/boost/log/sources/basic_logger.hpp:37:
In file included from /usr/local/include/boost/log/sources/severity_logger.hpp:27:
In file included from /usr/local/include/boost/log/trivial.hpp:25:
In file included from /Volumes/Macintosh HD 2/code/Logging Tut 1/loggingTut1/loggingTut1/main.cpp:18:
Overloaded 'operator>>' must have at least one parameter of class or enumeration type in /usr/local/include/boost/log/utility/explicit_operator_bool.hpp
仔细看看周围是否有人有类似的东西,我什么也没发现——那么有人能解释一下我错过了什么或者问题出在哪里吗
详细信息:
我正在使用Xcode 4.0.2在OSX(10.6.8)上尝试这一点
我已经下载并构建了1_46_1 boost版本,该版本与我的主要基于boost的项目(使用boost Asio、boost线程等)配合得很好
Boost.log
还不在主版本中,因此我从sourceforge下载了它,如下所示:
我将boost/log
目录从下载的分支复制到boost\u 1\u 46\u 1/boost/log
目录,并将libs/log
目录复制到boost\u 1\u 46\u 1/libs/log
我删除了/usr/local/include/boost
和/usr/local/lib
中的所有boost内容,然后使用以下方法重新构建:
/bootstrap.sh--with libraries=all--prefix=/usr/local--includedir=/usr/local/include--libdir=/usr/local/lib
接
sudo./bjam安装>build.log
我检查了输出是否有错误,它看起来很干净-没有任何报告。我在/usr/local
下有所有的boost库和标题。我检查了我的Asio项目,它在这个构建中运行良好(没有boost日志)。我为日志教程创建了一个新项目,设置了库路径和include路径,并将lboost_log添加到链接器选项中
当尝试使用Boost日志的教程程序时会出现问题-如Boost日志文档或svn文件中包含的示例所述
SVN的示例如下所示:
/*
* Copyright Andrey Semashev 2007 - 2011.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file main.cpp
* \author Andrey Semashev
* \date 07.11.2009
*
* \brief An example of trivial logging.
*/
// #define BOOST_ALL_DYN_LINK 1
// #define BOOST_LOG_DYN_LINK 1
#include <boost/log/trivial.hpp>
#include <boost/log/core.hpp>
#include <boost/log/filters.hpp>
int main(int argc, char* argv[])
{
// Trivial logging: all log records are written into a file
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";
// Filtering may also be applied
using namespace boost::log;
core::get()->set_filter
(
filters::attr< trivial::severity_level >("Severity") >= trivial::info
);
// Now the first two lines will not pass the filter
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";
return 0;
}
所以,这有点像是在回答我自己的问题(因为它可能会帮助其他Xcode/OSX用户) 查看explicit_operator.bool.hpp文件,其中有一些条件代码,允许我们通过设置以下内容绕过问题模板:
#define BOOST_LOG_NO_UNSPECIFIED_BOOL
然后为我编译并运行教程
我不确定的是为什么需要这样做,或者下游可能会产生什么影响(请注意,像许多用户一样,我对一种快速有效的方法感兴趣,以获得一个轻量级日志框架,如果我们必须花时间研究框架的内部工作,它会使这一点无效……)
正如评论所说,它还不是一个受支持的图书馆,因此在现阶段期望过高可能是不公平的
Chrisboost::log还不是受支持的boost库。因此,它不会在所有可能的平台和编译器上编译也就不足为奇了。。
/usr/local/include/boost/log/utility/explicit_operator_bool.hpp:67:29: error: overloaded 'operator>>' must have at least one parameter of class or enumeration type [2]
In file included from /usr/local/include/boost/log/attributes/attribute_name.hpp:27:
In file included from /usr/local/include/boost/log/attributes/attribute_set.hpp:28:
In file included from /usr/local/include/boost/log/sources/basic_logger.hpp:37:
In file included from /usr/local/include/boost/log/sources/severity_logger.hpp:27:
In file included from /usr/local/include/boost/log/trivial.hpp:25:
In file included from /Volumes/Macintosh HD 2/code/Logging Tut 1/loggingTut1/loggingTut1/main.cpp:18:
Overloaded 'operator>>' must have at least one parameter of class or enumeration type in /usr/local/include/boost/log/utility/explicit_operator_bool.hpp
#define BOOST_LOG_NO_UNSPECIFIED_BOOL