将头文件放在哪里以便所有 .cpp 程序都可以访问它们?

Where to put header files in order to make them accessible for all .cpp programs?

There's a "filesystem" library in my laptop. 当我编译代码时I get an error. I tried putting -lstdc++fs in the compile command, but it didn't work. It should, according to GCC manual。我该怎么办?我想我迷路了。

我的 GCC 版本是 6.3.0.

编辑: 也不起作用。

 Directory of C:\MinGW\lib\gcc\mingw32.3.0\include\c++\experimental

12.04.2021  19:16    <DIR>          .
12.04.2021  19:16    <DIR>          ..
29.05.2017  23:00             4 903 algorithm
29.05.2017  23:00            14 716 any
29.05.2017  23:00             3 187 array
12.04.2021  19:16    <DIR>          bits
29.05.2017  23:00             1 976 chrono
29.05.2017  23:00             2 356 deque
29.05.2017  23:00             2 412 forward_list
29.05.2017  23:00            14 093 functional    
29.05.2017  23:00             3 594 iterator
29.05.2017  23:00             2 323 list
29.05.2017  23:00             2 667 map
29.05.2017  23:00             6 063 memory
29.05.2017  23:00            11 928 memory_resource
29.05.2017  23:00             3 114 numeric
29.05.2017  23:00            28 890 optional
29.05.2017  23:00            15 285 propagate_const
29.05.2017  23:00             2 361 random
29.05.2017  23:00             2 455 ratio
29.05.2017  23:00             2 163 regex
29.05.2017  23:00             2 541 set
29.05.2017  23:00             2 927 string
29.05.2017  23:00            21 233 string_view
29.05.2017  23:00             2 062 system_error
29.05.2017  23:00             2 524 tuple
29.05.2017  23:00            11 057 type_traits
29.05.2017  23:00             2 913 unordered_map
29.05.2017  23:00             2 796 unordered_set
29.05.2017  23:00             1 633 utility
29.05.2017  23:00             2 428 vector
              28 File(s)        176 600 bytes
               3 Dir(s)  282 055 958 528 bytes free    

当您使用 GCC 6 时,您不仅需要添加 -lstdc++fs,还需要包括 <experimental/filesystem>:

g++ file.cpp -lstdc++fs

您还需要记住,您正在使用实验库,因此您也需要使用实验命名空间:

#include <experimental/filesystem>

using fs = std::experimental::filesystem;

如果您不想被迫在 header 路径中使用 experimental 您需要将 GCC 更新到版本 8 或更高版本并使用