Using <experimental/filesystem> with CMake

149 views Asked by At

I was using CMake to build a project that requires <experimental/filesystem> in C++14. And I got undefined symbol: _ZNSt12experimental10filesystem2v17__cxx114path14_M_split_cmptsEv when running the binary.

Did I miss anything in the cmakelist.txt?

1

There are 1 answers

0
Some programmer dude On

In this answer I'm assuming you have an older version of GCC, which doesn't support C++17 or std::filesystem.

For older versions of GCC, the filesystem library isn't part of the main standard library.

Instead it comes as a separate library that you need to explicitly link with.

If you don't already have a target_link_libraries command you need to add one for your target, that links with the stdc++fs library.