我该怎么做才能在Visual Studio 2013中为我的c ++项目使用boost库

时间:2014-06-24 19:34:47

标签: c++ boost visual-studio-2013

大家好,这是我第一次在c ++项目中使用boost库,所以我真的不知道该怎么办。

以下是与boost相关的代码的一部分:

#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/variant/recursive_wrapper.hpp>
#include <boost/lexical_cast.hpp>

namespace qi = boost::spirit::qi;
namespace phx = boost::phoenix;

struct op_or  {};
struct op_and {};
struct op_not {};

typedef std::string var;
template <typename tag> struct binop;
template <typename tag> struct unop;

我已下载boost_1_55并摘录boost/spiritboost/variant/recursive_wrapper.hppboost/lexical_cast.hpp  进入C://。之后我通过右键单击项目并选择添加现有项目将它们添加到我的项目中。 现在,如果我用下面的

替换我的标题
#include "qi.hpp"
#include "phoenix.hpp"
#include "phoenix_operator.hpp"
#include "recursive_wrapper.hpp"
#include "lexical_cast.hpp"
头文件上的

错误消失了,但编译器仍然在以下位置出错:

 #include <boost/variant/recursive_wrapper.hpp>
 #include <boost/lexical_cast.hpp>

行。它表示“错误名称后跟::必须是类或命名空间”。那么有谁知道我该怎么办?

1 个答案:

答案 0 :(得分:1)

执行此操作的简便方法是安装最新版本的NuGet。 然后使用扩展程序库搜索/查找/安装boost nuget package

添加的boost.targets将添加自动添加路径以解析libs和标题。