Vasseurth
Vasseurth

Reputation: 6476

Make error library not found for -lstdc++fs

When compiling code examples from a textbook, I run into a compilation error: ld: library not found for -lstdc++fs. What does this error mean and how can I get around it?

% make filesystem           
Consolidate compiler generated dependencies of target filesystem
[100%] Linking CXX executable filesystem
ld: library not found for -lstdc++fs
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [chapter_17/filesystem] Error 1
make[2]: *** [chapter_17/CMakeFiles/filesystem.dir/all] Error 2
make[1]: *** [chapter_17/CMakeFiles/filesystem.dir/rule] Error 2
make: *** [filesystem] Error 2

Upvotes: 1

Views: 2672

Answers (2)

vmp
vmp

Reputation: 1

I use

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -lstdc++")

and

target_link_libraries(qdvdauthor stdc++)

with cmake for Mageia 10.

Upvotes: 0

Vasseurth
Vasseurth

Reputation: 6476

In short, linking stdc++fs is not longer necessary as it has been incorporated into the base library.

When the textbook was first written the C++ libraries didn't officially support filesystem yet, so they would require a secondary library called stdc++fs. This was a libstdc++ specific library that imported the C++17 features that weren't in the official library yet.

Now, both GCC's libstdc++ and Clang's libc++ include it in their base library, and the stdc++fs library got dropped.

You can drop the linking to that library without any problems; it patched a problem in compiler support that's no longer relevant

Upvotes: 4

Related Questions