Maison > Article > développement back-end > Comment résoudre les erreurs de l'éditeur de liens lors de l'utilisation de « experimental ::filesystem » dans GCC ?
When attempting to utilize the latest C++1z features with GCC 6.0, particularly with the experimental::filesystem library, you may encounter a linker error like this:
undefined reference to `std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts()'
It's important to note that the Filesystem TS (Technical Specification) is not part of the C++1z (now C++20) standard. Hence, the error is not related to C++1z support but to linking with the appropriate library.
To resolve the issue, link your code with the static library -lstdc++fs. This will provide the necessary implementation for the experimental::filesystem features. Remember to place it after any objects that depend on it in the linker command.
November 2017:
GCC 8.x introduces a C++17-compliant Filesystem library under the namespace std::filesystem. It requires both -std=gnu++17 and -lstdc++fs for usage.
January 2019:
GCC 9 allows the use of std::filesystem components without -lstdc++fs.
April 2024:
GCC 13.3 presents experimental::filesystem symbols in -lstdc++exp, alongside other experimental definitions.
Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!