Linker troubles with C++17 filesystem library

CodeLite installation/troubleshooting forum
CodeLite Enthusiast
Posts: 12
Joined: Sat Mar 26, 2011 4:22 pm
Genuine User: Yes
IDE Question: C++

Linker troubles with C++17 filesystem library

Post by robinwhittle » Sat Aug 17, 2019 3:15 pm

On an x86_64 Debian 10 system I built Codelite from the 13.0 tar.gz file, from the "Download CodeLite 13.0 tar.gz from GitHub" link at Thanks for this - I prefer a known good body of source code to downloading the current state of the git repository. All the dependency stuff goes very smoothly now, thanks to notes at .

I had all sorts of linker trouble when compiling (GCC 8.3) a simple example program: , including:

undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()

This was despite adding the two required options for the compiler -std=c++17 and -lstdc++fs . The second must be at or I guess near the end. All the guidance I could find regarding using this library states that it is part of C++17, that GCC 8.x supports it and that since it is not integrated with the main standard library, but is a separate file (for me: /usr/lib/gcc/x86_64-linux-gnu/8/libstdc++fs.a) that this special option was needed so g++ would instruct the linker to link this library in.

I found it didn't matter whether the library file was there or not. I also found that when it is there, a plain g++ command line with these two options compiled and linked the program just fine.

The problem was that adding these to options to: "Project (right click) > Settings > Compiler > C++ Compiler Options" only affected the one or more command lines which Codelite generates to make g++ compile the one or more items of source code. What is required, in addition, is adding -lstdc++fs to the item below: Project (right click) > Settings > Linker > Linker Options .

I read that the need for this option is only for GCC 8.x and that with 9.x there will be no need for it.

I haven't used this library to any significant degree yet. I am working from the pages and I found a tutorial at the Boost site ... /index.htm from which this library originated. However, the two libraries are different in some ways: , ... system.htm and .

As always, thanks for Codelite!