Home > Backend Development > C++ > How do I fix the linker error when using experimental::filesystem in C 1z?

How do I fix the linker error when using experimental::filesystem in C 1z?

Susan Sarandon
Release: 2024-11-15 03:45:02
Original
604 people have browsed it

How do I fix the linker error when using experimental::filesystem in C  1z?

How to Resolve experimental::filesystem Linker Error in C 1z

In C 1z development, users attempting to leverage the new experimental::filesystem library have encountered a linker error. This issue is distinct from C 1z support, as experimental::filesystem is a separate specification.

To resolve the issue, users must link their code with the appropriate library. For GCC 5.3 and later, use the -lstdc fs flag:

g++ main.cpp -O2 -g -o go -lstdc++fs
Copy after login

This library should be placed after any objects that rely on it in the linker command since it is a static library.

Updates:

  • November 2017: GCC 8.x introduces an implementation of the C 17 Filesystem library in the std::filesystem namespace. When using -std=gnu 17 or -std=c 17, -lstdc fs is still required.
  • January 2019: GCC 9 eliminates the need for -lstdc fs for C 17 std::filesystem components.
  • April 2024: GCC 13.3 adds std::experimental::filesystem symbols to -lstdc exp.

The above is the detailed content of How do I fix the linker error when using experimental::filesystem in C 1z?. 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