Error c1083 cannot open include file no such file or directory

C++ Documentation. Contribute to MicrosoftDocs/cpp-docs development by creating an account on GitHub.
description title ms.date f1_keywords helpviewer_keywords ms.assetid

Learn more about: Fatal Error C1083

Fatal Error C1083

09/01/2017

C1083

C1083

97e52df3-e79c-4f85-8f1e-bbd1057d55e7

Cannot open filetype file: ‘file‘: message

The compiler generates a C1083 error when it can’t find a file it requires. There are many possible causes for this error. An incorrect include search path or missing or misnamed header files are the most common causes, but other file types and issues can also cause C1083. Here are some of the common reasons why the compiler generates this error.

The specified file name is wrong

The name of a file may be mistyped. For example,

#include <algorithm.h>

might not find the file you intend. Most C++ Standard Library header files do not have a .h file name extension. The <algorithm> header would not be found by this #include directive. To fix this issue, verify that the correct file name is entered, as in this example:

#include <algorithm>

Certain C Runtime Library headers are located in a subdirectory of the standard include directory. For example, to include sys/types.h, you must include the sys subdirectory name in the #include directive:

#include <sys/types.h>

The file is not included in the include search path

The compiler cannot find the file by using the search rules that are indicated by an #include or #import directive. For example, when a header file name is enclosed by quotation marks,

#include "myincludefile.h"

this tells the compiler to look for the file in the same directory that contains the source file first, and then look in other locations specified by the build environment. If the quotation marks contain an absolute path, the compiler only looks for the file at that location. If the quotation marks contain a relative path, the compiler looks for the file in the directory relative to the source directory.

If the name is enclosed by angle brackets,

#include <stdio.h>

the compiler follows a search path that is defined by the build environment, the /I compiler option, the /X compiler option, and the INCLUDE environment variable. For more information, including specific details about the search order used to find a file, see #include Directive (C/C++) and #import Directive.

If your include files are in another directory relative to your source directory, and you use a relative path in your include directives, you must use double quotes instead of angle brackets. For example, if your header file myheader.h is in a subdirectory of your project sources named headers, then this example fails to find the file and causes C1083:

#include <headersmyheader.h>

but this example works:

#include "headersmyheader.h"

Relative paths can also be used with directories on the include search path. If you add a directory to the INCLUDE environment variable or to your Include Directories path in Visual Studio, do not also add part of the path to the include directives. For example, if your header is located at pathexampleheadersmyheader.h, and you add pathexampleheaders to your Include Directories path in Visual Studio, but your #include directive refers to the file as

#include <headersmyheader.h>

then the file is not found. Use the correct path relative to the directory specified in the include search path. In this example, you could change the include search path to pathexample, or remove the headers path segment from the #include directive.

Third-party library issues and vcpkg

If you see this error when you are trying to configure a third-party library as part of your build, consider using vcpkg, a C++ package manager, to install and build the library. vcpkg supports a large and growing list of third-party libraries, and sets all the configuration properties and dependencies required for successful builds as part of your project.

The file is in your project, but not the include search path

Even when header files are listed in Solution Explorer as part of a project, the files are only found by the compiler when they are referred to by an #include or #import directive in a source file, and are located in an include search path. Different kinds of builds might use different search paths. The /X compiler option can be used to exclude directories from the include search path. 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. For more information about the /X compiler option, see /X (Ignore Standard Include Paths).

To fix this issue, correct the path that the compiler uses to search for the included or imported file. A new project uses default include search paths. You may have to modify the include search path to add a directory for your project. If you are compiling on the command line, add the path to the INCLUDE environment variable or the /I compiler option to specify the path to the file.

To set the include directory path in Visual Studio, open the project’s Property Pages dialog box. Select VC++ Directories under Configuration Properties in the left pane, and then edit the Include Directories property. For more information about the per-user and per-project directories searched by the compiler in Visual Studio, see VC++ Directories Property Page. For more information about the /I compiler option, see /I (Additional Include Directories).

The command line INCLUDE or LIB environment is not set

When the compiler is invoked on the command line, environment variables are often used to specify search paths. If the search path described by the INCLUDE or LIB environment variable is not set correctly, a C1083 error can be generated. We strongly recommend using a developer command prompt shortcut to set the basic environment for command line builds. For more information, see Build C/C++ on the Command Line. For more information about how to use environment variables, see How to: Use Environment Variables in a Build.

The file may be locked or in use

If you are using another program to edit or access the file, it may have the file locked. Try closing the file in the other program. Sometimes the other program can be Visual Studio itself, if you are using parallel compilation options. If turning off the parallel build option makes the error go away, then this is the problem. Other parallel build systems can also have this issue. Be careful to set file and project dependencies so build order is correct. In some cases, consider creating an intermediate project to force build dependency order for a common file that may be built by multiple projects. Sometimes antivirus programs temporarily lock recently changed files for scanning. If possible, consider excluding your project build directories from the antivirus scanner.

The wrong version of a file name is included

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. For example, certain files may only apply to x86 builds, or to Debug builds. 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 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 pch.cpp file (stdafx.cpp in Visual Studio 2017 and earlier) is automatically created in the project directory for new 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.

Additional causes

  • You have installed an SDK or third-party library, but you have not opened a new developer command prompt window after the SDK or library is installed. If the SDK or library adds files to the INCLUDE path, you may need to open a new developer command prompt window to pick up these environment variable changes.

  • 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 or directory was created by the Windows Subsystem for Linux, per-directory case sensitivity is enabled, and the specified case of a path or file does not match the case of the path or file on disk.

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

  • Visual Studio or the command line tools do not have sufficient permissions to read the file or the directory. This can happen, for example, when the project files have different ownership than the process running Visual Studio or the command line tools. Sometimes this issue can be fixed by running Visual Studio or the developer command prompt as Administrator.

  • 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.

Example

The following example generates a C1083 error when the header file "test.h" does not exist in the source directory or on the include search path.

// 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 Projects and build systems.

See also

  • MSBuild Properties

Either move the xyz.h file somewhere else so the preprocessor can find it, or else change the #include statement so the preprocessor finds it where it already is.

Where the preprocessor looks for included files is described here. One solution is to put the xyz.h file in a folder where the preprocessor is going to find it while following that search pattern.

Alternatively you can change the #include statement so that the preprocessor can find it. You tell us the xyz.cxx file is is in the ‘code’ folder but you don’t tell us where you’ve put the xyz.h file. Let’s say your file structure looks like this…

<some folder>xyz.h
<some folder>codexyz.cxx

In that case the #include statement in xyz.cxx should look something like this..

#include "..xyz.h"

On the other hand let’s say your file structure looks like this…

<some folder>includexyz.h
<some folder>codexyz.cxx

In that case the #include statement in xyz.cxx should look something like this..

#include "..includexyz.h"

Update: On the other other hand as @In silico points out in the comments, if you are using #include <xyz.h> you should probably change it to #include "xyz.h"

  • Remove From My Forums
  • Question

  • Hi,

    I am trying to build a solution which has two projects, one of these is a library which must be compiled, and is a dependency of the main project. This library appear to build fine. However, when trying to build the main project I get the error:

    fatal error C1083: Cannot open include file: ‘lualib.h’: No such file or directory

    lualib.h is included with the directive #include «lualib.h»  in the file that throws the error, and is a header file in the directory of the library. The library the following directory relative to the main projects directory:..lualiblualib relative
    to the main project directory. I have added this directory to the locations to look for header files by going to the main project preferences and adding this directory as a reference directory.

    Nothing stops the error, any suggestions as to what I’m doing wrong?

Answers

  • Well, even though none of what you said holds any relevence to Visual Studio itself, the problem is that the reference paths are for C++/CLI when you use the #using directive. For .h files you need to set the Include paths, this will add paths to what VC
    looks in when you use the #include directive.

    So to do this in Visual Studio, open up Solution Explorer, right click on the main project’s name and then select Properties. In the window that appears go to Configuration Properties->C/C++->General and in Additional Include Directories add the path
    to the header files. This can be relative or absolute. You must do this for all configurations in your project. Please note that it must be Include for the compiler to associate that with the #include directive. So if you are modifying another IDE then look
    out for Include.

    The directions that I gave will work on VC8 and newer (they should also work on VC7 and 7.1) but I don’t know VC 6. So if you are using that then again, look out for the Additional Include Directories setting.


    This is a signature

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts
    is to aid in the learning process.

    Do you want Visual Studio 11 Express to be freely installable on Windows 7 and able to write regular C++ applications? Please vote for

    this.

    • Edited by

      Saturday, March 3, 2012 12:00 PM

    • Marked as answer by
      crobar
      Sunday, March 4, 2012 11:02 PM

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#include "stdafx.h"
#include "iostream"
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib") 
 
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
 
HWND    hWnd;
HDC     hDC;
HGLRC   hRC;
 
// Set up pixel format for graphics initialization
void SetupPixelFormat()
{
    PIXELFORMATDESCRIPTOR pfd, *ppfd;
    int pixelformat;
 
    ppfd = &pfd;
 
    ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR);
    ppfd->nVersion = 1;
    ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
    ppfd->dwLayerMask = PFD_MAIN_PLANE;
    ppfd->iPixelType = PFD_TYPE_COLORINDEX;
    ppfd->cColorBits = 16;
    ppfd->cDepthBits = 16;
    ppfd->cAccumBits = 0;
    ppfd->cStencilBits = 0;
 
    pixelformat = ChoosePixelFormat(hDC, ppfd);
    SetPixelFormat(hDC, pixelformat, ppfd);
}
 
// Initialize OpenGL graphics
void InitGraphics()
{
    hDC = GetDC(hWnd);
 
    SetupPixelFormat();
 
    hRC = wglCreateContext(hDC);
    wglMakeCurrent(hDC, hRC);
 
    glClearColor(0, 0, 0, 0.5);
    glClearDepth(1.0);
    glEnable(GL_DEPTH_TEST);
}
 
// Resize graphics to fit window
void ResizeGraphics()
{
    // Get new window size
    RECT rect;
    int width, height;
    GLfloat aspect;
 
    GetClientRect(hWnd, &rect);
    width = rect.right;
    height = rect.bottom;
    aspect = (GLfloat)width / height;
 
    // Adjust graphics to window size
    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0, aspect, 1.0, 100.0);
    glMatrixMode(GL_MODELVIEW);
}
 
// Draw frame
void DrawGraphics()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
    // Set location in front of camera
    glLoadIdentity();
    glTranslated(0, 0, -10);
 
    // Draw a square
    glBegin(GL_QUADS);
    glColor3d(1, 0, 0);
    glVertex3d(-2, 2, 0);
    glVertex3d(2, 2, 0);
    glVertex3d(2, -2, 0);
    glVertex3d(-2, -2, 0);
    glEnd();
 
    // Show the new scene
    SwapBuffers(hDC);
}
 
// Handle window events and messages
LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM  wParam, LPARAM  lParam)
{
    switch (uMsg)
    {
    case WM_SIZE:
        ResizeGraphics();
        break;
 
    case WM_CLOSE: 
        DestroyWindow(hWnd);
        break;
 
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
 
    // Default event handler
    default: 
        return DefWindowProc (hWnd, uMsg, wParam, lParam); 
        break; 
    } 
 
    return 1; 
}
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
 
    const LPCWSTR appname = TEXT("OpenGL Sample");
 
    WNDCLASS wndclass;
    MSG      msg;
 
    // Define the window class
    wndclass.style         = 0;
    wndclass.lpfnWndProc   = (WNDPROC)MainWndProc;
    wndclass.cbClsExtra    = 0;
    wndclass.cbWndExtra    = 0;
    wndclass.hInstance     = hInstance;
    wndclass.hIcon         = LoadIcon(hInstance, appname);
    wndclass.hCursor       = LoadCursor(NULL,IDC_ARROW);
    wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wndclass.lpszMenuName  = appname;
    wndclass.lpszClassName = appname;
 
    // Register the window class
    if (!RegisterClass(&wndclass)) return FALSE;
 
    // Create the window
    hWnd = CreateWindow(
            appname,
            appname,
            WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
            CW_USEDEFAULT,
            CW_USEDEFAULT,
            800,
            600,
            NULL,
            NULL,
            hInstance,
            NULL);
 
    if (!hWnd) return FALSE;
 
    // Initialize OpenGL
    InitGraphics();
 
    // Display the window
    ShowWindow(hWnd, nCmdShow);
    UpdateWindow(hWnd);
 
    // Event loop
    while (1)
    {
        if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) == TRUE)
        {
            if (!GetMessage(&msg, NULL, 0, 0)) return TRUE;
 
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        DrawGraphics();
    }
 
    wglDeleteContext(hRC);
    ReleaseDC(hWnd, hDC);
}
  • Remove From My Forums
  • Question

  • Created in VS6

    Tried to compile in VS2005 Express and got the above error.

    Installed the latest Platform SDK which contains afxwin.h, but get the same error.

    Here is the code:

    // stdafx.h : include file for standard system include files,

    // or project specific include files that are used frequently, but

    // are changed infrequently

    //

    #if !defined(AFX_STDAFX_H__38F261C7_B9D0_11D1_94AA_444553540000__INCLUDED_)

    #define AFX_STDAFX_H__38F261C7_B9D0_11D1_94AA_444553540000__INCLUDED_

    #if _MSC_VER >= 1000

    #pragma once

    #endif // _MSC_VER >= 1000

    #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers

    #include <afxwin.h> // MFC core and standard components

    #include <afxext.h> // MFC extensions

    #ifndef _AFX_NO_AFXCMN_SUPPORT

    #include <afxcmn.h> // MFC support for Windows Common Controls

    #endif // _AFX_NO_AFXCMN_SUPPORT

    //{{AFX_INSERT_LOCATION}}

    // Microsoft Developer Studio will insert additional declarations immediately before the previous line.

    #endif // !defined(AFX_STDAFX_H__38F261C7_B9D0_11D1_94AA_444553540000__INCLUDED_)

Answers

  • You need to add «C:Program FilesMicrosoft Platform SDKIncludemfc» to your INCLUDE path. The libraries are in «C:Program FilesMicrosoft Platform SDKlib». FYI, this is also version of MFC/ATL/CRT based on VC6.

    Thanks,
    Nikola
    VC++

Здравствуйте.
Пытаюсь выполнить установку библиотеки sasl
install python sasl

в процессе инсталляции возвращается ошибка

"C:Program Files (x86)Microsoft Visual Studio 14.0VCBINx86_amd64cl.exe" /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Isasl -Ic:python37include -Ic:python37include "-IC:Program Files (x86)Microsoft Visual Studio 14.0VCINCLUDE" "-IC:Program Files (x86)Windows Kits10include10.0.10240.0ucrt" "-IC:Program Files (x86)Windows Kits8.1includeshared" "-IC:Program Files (x86)Windows Kits8.1includeum" "-IC:Program Files (x86)Windows Kits8.1includewinrt" /EHsc /Tpsasl/saslwrapper.cpp /Fobuildtemp.win-amd64-3.7Releasesasl/saslwrapper.obj
returned error

        c:usersuser1appdatalocaltemppip-build-cwta78p2saslsaslsaslwrapper.h(22): fatal error
 C1083: Cannot open include file: 'sasl/sasl.h': No such file or directory

    error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.ex
e' failed with exit status 2

Попробовал выполнить команду отдельно, вернулась ошибка:

c1xx: fatal error C1083: Cannot open source file: 'sasl/saslwrapper.cpp': No such file or directory

Как решить эту проблему?

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Error c compiler cannot create executables centos
  • Error byte was not declared in this scope
  • Error by extcap pipe
  • Error by default updating the current branch in a non bare repository
  • Error bwipp ean13badcheckdigit incorrect ean 13 check digit provided перевод

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии