无法针对OS X上的Boost.log进行编译

时间:2011-07-04 15:29:30

标签: c++ logging boost xcode4

我正在尝试构建并运行Boost.log的教程示例并获得编译器错误,这些错误让我难以理解并可以使用一些帮助。基本细节;我已经在包含boost.log的OS X上完成了一系列的提升,但是当我尝试编译任何教程示例时,我从boost日志的'operator>>'内部得到一个重载的'trivial.hpp'错误文件。

报告错误在

log/utility/explicit_operator_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

好好环顾四周,看看是否有其他人有类似的东西,我什么也没找到 - 所以有人可以解释我错过了什么或问题可能是什么?

详细信息:

我在OS X(10.6.8)上使用Xcode 4.0.2

尝试这个

我已经下载并构建了1_46_1 boost版本,并且可以正常使用我的主要基于boost的项目(使用Boost Asio,提升线程等)。

Boost.log不在主构建中,所以我从sourceforge下载了这个问题: boost-log-how-to-get-it-and-how-to-build-it

我将boost/log目录从下载的分支复制到boost_1_46_1/boost/log目录,并将libs/log目录复制到boost_1_46_1/libs/log

我从/usr/local/include/boost/usr/local/lib删除了所有提升内容,然后使用以下方法重新构建:

./bootstrap.sh --with-libraries=all --prefix=/usr/local --includedir=/usr/local/include --libdir=/usr/local/lib

接着是

sudo ./bjam install > build.log

我检查输出是否有错误,看起来很干净 - 没有报道。我在/usr/local下有所有的boost库和标题。我检查了我的Asio项目,它对这个版本都没有问题(没有增强日志)。我为日志教程创建了一个新项目,设置了库路径和包含路径,并将lboost_log添加到链接器选项中。

当尝试使用Boost日志的教程程序时出现问题 - 详情请参阅Boost日志文档here或svn here

中文件中包含的示例

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

当我构建代码时,我遇到两个错误:

语义问题   重载'运算符&gt;&gt;'必须至少有一个类或枚举类型的参数 语义问题   重载'运算符&lt;&lt;'必须至少有一个类或枚举类型的参数

并在Boost Log的文件explicit_operator_bool.hpp中报告错误:

.
.
.
} // namespace boost

// These operators are not found through ADL
template< typename T > void operator<< (T const&,     boost::log::aux::unspecified_bool_type);
template< typename T > void operator>> (T const&, boost::log::aux::unspecified_bool_type);

#define BOOST_LOG_EXPLICIT_OPERATOR_BOOL()\
.
.
.

我在Xcode中获得的堆栈如下:

/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

1 个答案:

答案 0 :(得分:1)

所以有点回答我自己的问题(因为它可能有助于其他Xcode / OSX用户)。

查看explicit_operator.bool.hpp文件,其中有一些条件代码允许我们通过设置来绕过问题模板:

#define BOOST_LOG_NO_UNSPECIFIED_BOOL

教程然后为我编译并运行。

我不确定的是为什么需要它或者下游的影响可能是什么(请注意,像许多用户一样,我对快速有效地获取轻量级日志框架感兴趣,如果我们必须花时间调查框架的内部工作,它有点无效......)

正如评论所说,它还不是一个受支持的图书馆,所以在这个阶段对它的期望太高是不公平的。

克里斯