c++ - Boost预编译头文件问题

标签 c++ gcc boost precompiled

我尝试预编译 Boost header 。

第一个实验 - 使用 std:: header 。我创建文件 std.hpp:

#include <vector>
#include <iostream>
// And other std:: headers

之后:

g++ std.hpp

将std.hpp.gch复制到/usr/include/c++/4.4.5

并编写测试程序:

#include <std.hpp>

int main() {
    std::cout << "Hello, precompiled world!" << std::endl;
    return 0;
}

工作正常。

现在尝试预编译 Boost header 。

我创建了 boost.hpp 文件:

#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/karma.hpp>

之后:

g++ boost.hpp

将boost.hpp.gch复制到/usr/local/include/boost

并编写测试程序:

#include <boost/boost.hpp>

int main() {
    // Some code...
    return 0;
}

但出现错误:

main.cpp:2:33: error: /usr/local/include/boost/boost.hpp: No such file or directory.

尝试,进行实验:

#include </usr/local/include/boost/boost.hpp>

int main() {
    // Some code...
    return 0;
}

同样的错误。

尝试在另一个地方复制 boost.hpp.gch - 同样的错误。

如果我将文件 boost.hpp 放在同一个地方 - 工作正常(所以路径没有问题):

ls /usr/local/include/boost | grep boost
boost.hpp
boost.hpp.gch

因此编译器使用 boost.hpp header 。但是为什么编译器看不到预编译的 boost.hpp.gch??

最佳答案

这可能是 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46110 中记录的 gcc 错误

关于c++ - Boost预编译头文件问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5191467/

相关文章:

c++ - 具有已知参数的函数指针

c++ - 如何使用 for 循环回到起点?

c++ - 使用类内成员初始化委托(delegate)构造函数

c++ - 如何循环遍历映射并将值分配给 C++ 中的数组?

c - 告诉 C 内联函数但仍然可以调用调试器

c - 为什么 a*b/c 而不是 a*(b/c) 在 AVR 上提供 3 倍大的程序大小?

python - pip install lxml centOSFailed building wheel for lxml

c++ - 使用 apt 安装在 Ubuntu 20.04 LTS 上找不到 c++ boost 头文件

c++ - 如何使用 boost::program_options 接受可选标志?

c++ - 为什么 boost::program_options 接受切词?