简体   繁体   English

在Visual Studio 2013中为我的C ++项目使用Boost库我应该怎么做

[英]what should I do to use boost library for my c++ project in VisualStudio 2013

Hi everyone this is my first time for using boost library in c++ project so I actually dont know what should I do for it. 大家好,这是我第一次在c ++项目中使用boost库,所以我实际上不知道该怎么做。

Here is part of my code that is related with 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;

I've downloaded boost_1_55 and extract boost/spirit , boost/variant/recursive_wrapper.hpp and boost/lexical_cast.hpp into C:// .After that I've added them into my project by right clicking project and choosing add existing item . 我已经下载了boost_1_55,并将boost/spiritboost/variant/recursive_wrapper.hppboost/lexical_cast.hpp提取到C://中。之后,通过右键单击项目并选择添加现有项,将它们添加到我的项目中。 Now, If I replace my headers with below 现在,如果我将标题替换为以下内容

#include "qi.hpp"
#include "phoenix.hpp"
#include "phoenix_operator.hpp"
#include "recursive_wrapper.hpp"
#include "lexical_cast.hpp"

errors on header files are gone but compiler still gives error at : 头文件上的错误已消失,但编译器仍在以下位置给出错误:

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

lines. 线。 It says that " error name followed by :: must be a class or namespace ". 它说“ 错误名称后跟::必须是类或名称空间 ”。 So is there anyone to know what should I do ? 那么,有谁知道我该怎么办?

An easy way to do this would be to install the latest version of NuGet . 一种简单的方法是安装最新版本的NuGet Then use the Extension Gallery to search/find/install the boost nuget package . 然后使用扩展库搜索/查找/安装boost nuget软件包

The added boost.targets will add the automatically add the paths to resolve the libs and headers for you. 添加的boost.targets将添加自动添加的路径来为您解析库和标头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM