Fatal Error C1083

Cannot open filetype file: 'file': message

The compiler generates a C1083 error when it cannot find a file. This document describes circumstances that might lead to the error.

The path of the file is not included in the compiler search

By using the search rules that are indicated in an include directive, the compiler cannot find the file. For example, a header file name that is enclosed by quotation marks

#include "myincludefile.h" 

instructs the compiler to first look for the file in the directory that contains the source file that owns the include directive, and then look in other locations. If the name is enclosed by angle brackets

#include <stdio.h>

then the compiler follows a search path that is defined by using VC++ Directories, the /I compiler option, the /X compiler option, and/or the INCLUDE environment variable, depending on whether you are building from the IDE or on the command line. For more information, see #include Directive (C/C++).

A new project uses default search paths. You may have to modify the path to add a directory for your project. For more information about per-user and per-project VC++ Directories, see VC++ Directories Property Page. For more information about the /I compiler option, see /I (Additional Include Directories). For more information about the /X compiler option, see /X (Ignore Standard Include Paths).

Even when header files are listed in Solution Explorer, the files are found by the compiler when they are referred to by an include directive and are located on a directory search path, which is typically described under VC++ Directories. Different kinds of builds might use different search paths. This enables different builds to use different include files that have the same name, but are kept in different directories. This is an alternative to conditional compilation by using preprocessor commands.

  • A C1083 error can also indicate that the wrong version of a file is included. For example, a build could include the wrong version of a file that has an include directive for a header file that is not intended for that build. When the header file is not found, the compiler generates a C1083 error. The fix for this problem is to use the correct file, not to add the header file or directory to the build.

The specified file name is wrong

For example,

#include <algorithms.h>

might not find the correct file. There is a Standard C++ Library header file named algorithms that does not have a .h file name extension. It would not be found by this include directive.

  • When the compiler is invoked on the command line, environment variables are often used. If the search path described by an INCLUDEenvironment variable is set incorrectly, a C1083 error will be generated. For more information about how to use environment variables, see How to: Use Environment Variables in a Build.

The precompiled headers are not yet precompiled

When a project is configured to use precompiled headers, the relevant .pch files have to be created so that files that use the header contents can be compiled. For example, the stdafx.cpp file is automatically created in the project directory for new MFC projects. Compile that file first to create the precompiled header files. (In the typical build process design, this is done automatically.) For more information, see Creating Precompiled Header Files.

Note

The import directive may also generate a C1083 error, for the same reasons that the include directive does. For more information, see #import Directive (C++).

Several less likely causes

  • The file uses managed code, but the compiler option /clr is not specified. For more information, see /clr (Common Language Runtime Compilation).

  • The file is compiled by using a different /analyze compiler option setting than is used to precompile the headers. (When the headers for a project are precompiled, all should use the same /analyze settings.) For more information, see /analyze (Code Analysis).

  • The file, the directory, or the disk is read-only.

  • Access permissions for the file or the directory are not granted.

  • There are not enough file handles. Close some applications and then recompile. This condition is unusual under typical circumstances. However, it can occur when large projects are built on a computer that has limited physical memory.

The following example generates a C1083 error.

// C1083.cpp
// compile with: /c
#include "test.h"   // C1083 test.h does not exist
#include "stdio.h"   // OK

For information about how to build C/C++ projects in the IDE or on the command line, and information about setting environment variables, see Building C/C++ Programs.

See Also

Concepts

MSBuild Properties