how to use std::filesystem on gcc 8?

前端 未结 3 1356
挽巷
挽巷 2020-12-11 02:29

I have updated version of gcc, gcc --version produces the following output

    gcc (Ubuntu 8.1.0-5ubuntu1~16.04) 8.1.0
Copyright (C) 2018 Free Software Found         


        
相关标签:
3条回答
  • 2020-12-11 03:14

    Because of the silly rep system, I can't make this a comment on slashmais's answer.

    When using an IDE, make sure that you also set the compiler to be used to GCC8 or above.

    In my case, despite being installed, CodeLite was using a lower version of GCC and causing headaches (re: not finding the header)!

    Manually setting CodeLite to use gcc-8 (instead of just gcc fixed this problem.

    0 讨论(0)
  • 2020-12-11 03:22

    If you are using an IDE, eg codeblocks, then make sure the default compiler flags for gcc: -std=c++17 is set, not just the current project's, but the global flags.

    Had this issue with CB and setting this flag under [Settings/Compiler] fixed it (no need for adding the lib)

    0 讨论(0)
  • 2020-12-11 03:33

    Add the filesystem library as an argument to your compiler that will be forwarded to the linker. Also make sure you are using C++17. Both g++ and clang++ accepts this particular format:

    --std=c++17 -lstdc++fs
    
    0 讨论(0)
提交回复
热议问题