I want to use #include<dirent.h>
in my code but this error happen:
Cannot open include file: 'dirent.h': No such file or directory
How can I solve this problem ?
To make Dirent available to all C/C++ projects in your machine, simply copy include/dirent. h file to the system include directory, e.g. C:\Program Files\Microsoft Visual Studio 9.0\VC\include . Everything you need is included in the single dirent.
dirent. h is a header file that is found only on Linux systems. It provides data structures and function calls to open and read the contents of directories. If you are trying to port Linux code that uses this header file to Windows, you will that it is not available with Visual Studio.
h is the header in the C POSIX library for the C programming language that contains constructs that facilitate directory traversing. The function is not part of the C standard, but is considered "pseudo-standard" and is usually portable between platforms.
To use this, do the following: If you are using the MSVC toolset, you would have to clone the repository from https://github.com/tronkko/dirent. Copy the dirent. h from the include folder and paste it in C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.12.
Because this header file doesn't come with MSVC. Hence it cannot find it!
It comes with C POSIX library. The wikipedia says,
dirent.h is known to be included in the following compilers:
- Turbo C++ (DOS)
- GCC (Cross-platform)
- MinGW (Microsoft Windows)
- Borland C++ Builder (Microsoft Windows)
Microsoft Visual C++ does not include dirent.h
However, you can download free Windows implementation of dirent.h which you can use with Microsoft Visual Studio.
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