我写了一个test.cpp:
#include <iostream>
#include <stack>
#include <boost/lexical_cast.hpp>
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
using namespace std;
namespace phoenix = boost::phoenix;
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;
struct calculator
{
bool interpret(const string& s);
void do_neg();
void do_add();
void do_sub();
void do_mul();
void do_div();
void do_number(const char* first, const char* last);
int val() const;
private:
stack<int> values_;
int *pn1_, n2_;
void pop_1();
void pop_2();
};
......................
....................
但是当我使用g ++ test.cpp -o test时,会出现像boost/lexical_cast.hpp: No such file or directory
这样的错误,但我已将boost中的所有文件(从boost.org下载)复制到test.cpp文件夹,如何让g ++知道标题路径?感谢
我使用了g++ test.cpp -o test
使用" "
是不可能的,我有很多标头的依赖。
答案 0 :(得分:1)
您必须确保修改include to g ++的命令。阅读手册页(这是你最好的朋友):
Add the directory dir to the list of directories to be searched for
header files. Directories named by -I are searched before the
standard system include directories. If the directory dir is a
standard system include directory, the option is ignored to ensure
that the default search order for system directories and the
special treatment of system headers are not defeated . If dir
begins with "=", then the "=" will be replaced by the sysroot
prefix; see --sysroot and -isysroot.
对于你来说,命令应如下所示:
g++ -I path/to/boost test.cpp