Compilation issues when using #include<filesystem>
-
Thanks for the reply.
According to the link "Using this library may require additional compiler/linker options. GNU implementation prior to 9.1 requires linking with -lstdc++fs and LLVM implementation prior to LLVM 9.0 requires linking with -lc++fs"
So i added the following lines in .pro file
LIBS += -lstdc++fs
Still the same output.
P.S: I also tried
LIBS += -lc++fs
But the problem persists
-
@pingal
I do not know what precisely you are supposed to do here. But the errors you show earlier are compilation errors, so adding linker flags is not going to resolve that.... -
@JonB exactly, that's the compilation errors and has nothing to do with the linker but i followed notes Kent-Dorfman has suggested
I think this is some sort of bug (when std::filesystem is used in QT)
@pingal said in Compilation issues when using #include<filesystem>:
I think this is some sort of bug (when std::filesystem is used in QT)
Well you could test that in a standalone program without Qt?
I have seen possible issues like https://www.reddit.com/r/cpp_questions/comments/f10d31/comment/fh11qat/?utm_source=reddit&utm_medium=web2x&context=3
Your issue is most likely with MINGW. Its GCC may not be complete/up-to-date.
Maybe you could play at https://godbolt.org/ ?
-
Your compiler version (mingw8.1.0) is not suitable for the Qt version you are trying to compile with (6.0.2).
See here for an overview.
More specifically: for the MinGW version you use, you have to#include<experimental/filesystem>
which is why you get the error.
With more recent compilers (e.g. GCC10 or MinGW 11.2),-lstdc++fs
is no longer necessary. If the missing linking instruction was the problem, you'd have had a linker rather than a compiler error.
BRgds
Axel -
@Axel-Spoerl That really helped.
I've added QT 6.2.3 along with MinGW 9.0.0 to QT Creator and the problem is solved.
-
@Axel-Spoerl That really helped.
I've added QT 6.2.3 along with MinGW 9.0.0 to QT Creator and the problem is solved.
@pingal how did you fix this bug I have the same issue
-
@pingal how did you fix this bug I have the same issue
-
Your compiler version (mingw8.1.0) is not suitable for the Qt version you are trying to compile with (6.0.2).
See here for an overview.
More specifically: for the MinGW version you use, you have to#include<experimental/filesystem>
which is why you get the error.
With more recent compilers (e.g. GCC10 or MinGW 11.2),-lstdc++fs
is no longer necessary. If the missing linking instruction was the problem, you'd have had a linker rather than a compiler error.
BRgds
AxelThis post is deleted! -
@rowan-Samy
Since @pingal already wroteI've added QT 6.2.3 along with MinGW 9.0.0 to QT Creator and the problem is solved.
what have you done?
This post is deleted! -
This post is deleted!
@rowan-Samy
Seriously?- Install Qt 6.2.3.
- Install (may come with the Qt version) and use (select as kit) MinGW 9.0.0.
- See whether your problem has gone away.
If not then it appears you have a different problem from @pingal so there's no point asking him what he did.