2012-09-25 50 views
-1

库我写了一个TEST.CPP:C++使用升压库

 #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测试,有喜欢boost/lexical_cast.hpp: No such file or directory的错误,但我的所有文件拷贝的升压(从boost.org下载)到test.cpp文件夹,如何让g ++知道标题路径?由于

我用g++ test.cpp -o test

使用" "是不可能的,我有很多头的依赖。

+1

请务必添加升压转换器的路径包括G ++ ,用-IPath/to/boost执行此操作 – jozefg

+1

gcc test.cpp -IPath/to/boost -o test? –

+0

如果你使用'g ++',我会怀疑你在Unix系统上。使用你的包管理器来获得提升。它使生活更轻松。 – pmr

回答

1

你必须确保你修改了include到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