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)