首页 > 解决方案 > 使用已编译的 gcc 编译我的代码,但找不到某些头文件

问题描述

我从源代码编译 gcc9,并使用默认安装前缀:

./configure --disable-mutilib
make -j16
make install

之后,我发现 gcc 版本更新了:

which gcc
/usr/local/bin/gcc
gcc --version
gcc (GCC) 9.1.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

但是,当我在我的代码中使用它时:

#include <filesystem>
....

当我使用默认系统 gcc 时,我使用 cmake 编译它:

mkdir -p build
cmake ..
make

我得到了以下错误:

/root/cpp/main_demo.cpp:17:22:致命错误:文件系统:没有此类文件或目录编译终止。...

我确定该文件filesystem存在于我的安装路径中,因为我可以使用 `find /usr/local -iname ' filesystem ' 找到它。

我错过了什么,我怎样才能让它发挥作用?

标签: c++gcccmake

解决方案


推荐阅读