i'm facing a problem with filesystem library, it should be included in c++17 compiler, after 2 days i tried to install gcc-7.0.2 in raspberry pi but it didn't work, it couldn't recognize the command gcc-7 or g++-7 or even -std=c++17 so i had to install g++-6 and gcc-6 using apt-get install
anyway, after installing the 6 version the compiler include c++17.
i'm using codeblocks as IDE, i had to add a new compiler and add the option -std=c++17 to enable it,but in the main code when i include the filesystem library it says no such file or directory.
my question is, how i can add the c++17 compiler and its library (like filesystem) correctly ??
GCC v7 still does not implement <filesystem> but it does have the Filesystem Technical Specification which is in <experimental/filesystem>
#include <experimental/filesystem>
// for brevity
namespace fs = std::experimental::filesystem;
int main()
{
fs::path p = "/path/to/my/file"; // etc...
}
This is also available in GCC v6.
To link with the library you need to add -lstdc++fs to the command line.
Note: There may be some minor differences between the current Technical Specification and the final draft of <filesystem> that is decided upon by the Standards Committee.
Note 2: GCC v8 now implements <filesystem> with the -std=c++17 flag.
First you should take at look at C++17 Support in GCC
Runtime Library (libstdc++)
- Improved experimental support for C++17, including the following features:
- Deduction guides to support class template argument deduction.
std::filesystemimplementation.std::char_traits<char>andstd::char_traits<wchar_t>are usable in constant expressions.std::to_charsandstd::from_chars(for integers only, not for floating point types).
src: https://gcc.gnu.org/gcc-8/changes.html
Runtime Library (libstdc++)
- Improved support for C++17, including:
- The C++17 implementation is no longer experimental.
- Parallel algorithms and
<execution>(requires Thread Building Blocks 2018 or newer).<memory_resource>.- Using the types and functions in
<filesystem>does not require linking with-lstdc++fsnow.
src: https://gcc.gnu.org/gcc-9/changes.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With