Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<dirent.h> in visual studio 2010 or 2008

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 ?

like image 981
amiref Avatar asked Apr 03 '11 16:04

amiref


People also ask

How do I get Dirent h in Visual Studio?

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.

Is Dirent h in Windows?

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.

What is #include Dirent H?

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.

How do I add Dirent H to Visual Studio 2017?

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.


1 Answers

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.

like image 109
Nawaz Avatar answered Oct 24 '22 17:10

Nawaz