dirent.h

Good morning,
I have PGI 12.6 and I’m writing a C++ code in which I need of the dirent.h library to obtain the list of files in a folder.
Unfortunately when I compile with the command
“pgcpp -o code code.cpp” I obtain the error:

catastrophic error: cannot open source file “dirent.h”
#include <dirent.h>
^

can someone help me to solve this problem?
Thank you very much
Best regards
DS

Hi DS,

“dirent.h” is a POSIX system header file, so not something that ships with the compilers. If you’re on Linux, then this file is typically found in “/usr/include/dirent.h”.

Are you using Linux or Windows?

If on Linux, then you most likely have a configuration or installation issue with the compilers since “/usr/include” is part of the default include path.

Windows does not support POSIX so therefore does not include these header files. However, if you do a web search, you can find examples on adding this header file to for Windows, or how to translate POSIX calls to similar Windows system calls.

Hope this helps,
Mat