Home > Backend Development > C++ > body text

Why am I getting linker errors when using the experimental::filesystem library in GCC 6.0?

Barbara Streisand
Release: 2024-11-15 10:41:02
Original
948 people have browsed it

Why am I getting linker errors when using the experimental::filesystem library in GCC 6.0?

Linker Error with experimental::filesystem

When attempting to implement C 1z features using the experimental::filesystem library in GCC 6.0, users may encounter a linker error. The error message indicates an undefined reference to std::experimental::filesystem::v1::__cxx11::path::_M_split_cmpts().

Reason:

The Filesystem TS is not a part of C 1z but a separate specification. GCC's implementation of this library is available in C 11 mode.

Solution:

To resolve this issue, link with -lstdc fs. The libstdc fs.a library must come after objects that depend on it in the linker command.

Updates:

  • November 2017: GCC 8.x implemented the C 17 Filesystem library in the std::filesystem namespace. This library can be used with -std=gnu 17 or -std=c 17 and still requires linking with -lstdc fs.
  • January 2019: GCC 9 onwards allows the use of std::filesystem components without -lstdc fs.
  • April 2024: GCC 13.3 added std::experimental::filesystem symbols to -lstdc exp.

The above is the detailed content of Why am I getting linker errors when using the experimental::filesystem library in GCC 6.0?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template