473,414 Members | 1,618 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Error in compilation of C++ file with drent.h

6
Hi all, I am new to the VC++. I am stuck in trying to compile my read directory codes in C++. It keeps giving me this error:
Error 1 fatal error C1083: Cannot open include file: 'dirent.h': No such file or directory

Hope that there will be a solution to this. Many thanks.
Dec 20 '06 #1
7 8258
Banfa
9,065 Expert Mod 8TB
dirent.h is not a standard header so I assume it is one you have created. Is it in the same directory as your C/C++ source? If not have you provide the compiler with the correct path to it?
Dec 20 '06 #2
Ganon11
3,652 Expert 2GB
In your #include statements, are you trying to include "dirent.h"? If you are, you may have a spelling error keeping your program from finding the directory - either that, or the header file is not in the same folder as your main program.
Dec 20 '06 #3
facade
6
dirent.h is not a standard header so I assume it is one you have created. Is it in the same directory as your C/C++ source? If not have you provide the compiler with the correct path to it?
Ya. I had put it in the same folder as the source file. I also added into the same project as of the source file too.
Dec 20 '06 #4
Banfa
9,065 Expert Mod 8TB
Well then I would guess at a coding error, car to post the piece of coding exhibiting the error.
Dec 20 '06 #5
facade
6
Well then I would guess at a coding error, car to post the piece of coding exhibiting the error.
the whole code is as of below.

#include <sys/types.h>
#include <cstdlib>
#include <stdio.h>
#include <dirent.h>
#include <dir.h>
#include <errno.h>
#include <vector>
#include <string>
#include <iostream>
#include <fstream>

using namespace std;

/*function... might want it in some class?*/
int getdir (string dir, vector<string> &files)
{
DIR *dp;
struct dirent *dirp;
if((dp = opendir(dir.c_str())) == NULL) {
cout << "Error(" << errno << ") opening " << dir << endl;
return errno;
}

while ((dirp = readdir(dp)) != NULL) {
files.push_back(string(dirp->d_name));
}
closedir(dp);
return 0;
}

int main()
{
string dir = string(".");
vector<string> files = vector<string>();

getdir(dir,files);

for (unsigned int i = 0;i < files.size();i++) {
cout << files[i] << endl;
}
return 0;
}



the error msg is as of:

Error 1 fatal error C1083: Cannot open include file: 'dirent.h': No such file or directory
Dec 20 '06 #6
Ganon11
3,652 Expert 2GB
Try replacing

#include <dirent.h>

with

#include "dirent.h"

In my compiler (Bloodshed DevC++ 4.9.9.2), when including a header file defined by the programmer, it must be included with quotation marks instead of braces.
Dec 20 '06 #7
Banfa
9,065 Expert Mod 8TB
In my compiler (Bloodshed DevC++ 4.9.9.2), when including a header file defined by the programmer, it must be included with quotation marks instead of braces.
because < and > specifically instruct the compiler to not look in the directory the source code is in. They should only be used for standard library headers.
Dec 20 '06 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ex laguna | last post by:
I have run into this problem below with py2exe version 0.5.0 and python 2.3.3. Does anyone know a solution or workaround for this? Thanks much! ## Begin of test.py import shelve f =...
10
by: Sune | last post by:
Hi, previously I used Eclipse CDT for compiling my files just to get started with C and leave C++ behind. Now it's time to get a little more serious so I've moved my files to a new workplace and...
10
by: Brian Conway | last post by:
I have no idea what is going on. I have a Login screen where someone types in their login information and this populates a datagrid based off of the login. Works great in debug and test through...
1
by: Invalidlastname | last post by:
Hi, Our developer team recently started getting the compilation error, see below, once a while running the asp.net web application from Visual Studio 2003 (in debug mode), and we have to rebuild the...
2
by: Kevin R. | last post by:
I have been ignoring this problem for a few weeks now, but it's becoming a bit annoying not to mention unproductive. Here it goes: I compile my project with no errors. Then after I debug/run it,...
0
by: psilu | last post by:
Hi , I have created a virtual directory and copied my web services file to corresponding physical directory. But when i am trying to discover the webservice from virtual directory i am getting...
2
by: tshad | last post by:
This has been driving me crazy. I have been trying to get the error handling working on my system and can get parts of it working and others won't work at all. I found that you can't access...
0
by: roger23 | last post by:
I get this error C:\Program Files\MSBuild\Microsoft\WebDeployment\v8.0\Microsoft.WebDeployment.targets(526,9): error MSB6006: "aspnet_compiler.exe" exited with code 1. at the end of my build...
7
by: news.microsoft.com | last post by:
I have an asp.net 2.0 project that when I change the build configuration to release I get the following error: Command line error BC2014: the value 'None' is invalid for option 'debug'. If I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.