C++库使用提升库

C++ library in using boost library

本文关键字:C++      更新时间:2023-10-16

我写了一个测试.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

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

你必须确保

将包含修改为 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
相关文章:
  • 没有找到相关文章