Visual studio ошибка c1083

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

Fatal Error C1083

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

For people having problem related to «error C1083: Cannot open source file»:

Error is caused by settings in *.vcxproj file. Probably you deleted/moved source file by file explorer, not by Visual Studio’s «Solution Explorer». Thus, your *.vcxproj file is corrupted. Fix is to manually correct settings in *.vcxproj file.

How Visual Studio settings files work

Visual Studio saves solution’s info into file. This file is usually in project’s solution directory, has extension .sln and base name is same as name of solution, f.ex.:

NameOfSolution.sln

Similarly, project’s info is saved into one file (each project has its own file). Base name of this file is name of project, extension is .vcxproj, and usually is located in subdirectory named as your project, f.ex.:

NameOf1stProject/NameOf1stProject.vcxproj

NameOf2ndProject/NameOf2ndProject.vcxproj

Both *.sln and *.vcxproj files are textual files. You can open them by using Notepad.

How to fix problem

  1. Find *.vcxproj file responsible for your project.

    If you don’t know where it is, open in Notepad the *.sln file of your solution. Search for name of your solution. You will find line like:

    Project("{9AA9CEB8-8B4A-11D0-8D22-00B0C01AA943}") = "NameOf1stProject", "NameOf1stProjectNameOf1stProject.vcxproj", "{A8735D0A-25ED-4285-AB8F-AF578D8DB960}"
    

    Value under «NameOf1stProjectNameOf1stProject.vcxproj» is location of *.vcxproj file of your project.

  2. Open found *.vcxproj file by text editor (f.ex. Notepad).

  3. Search for line on which is filename you are struggling with.

    Example: if you are looking for «RemovedFile.cpp«, then you should find line:

    <ClCompile Include="RemovedFile.cpp" />
    
  4. Delete that line.

  5. If you have opened Visual Studio, it asks you if it should refresh solution — select yes. If it is not opened — just start using it.

  6. In case of any problems, try to rebuild solution (top banner -> Build -> Rebuild Solution)

In my cases, it worked. 30 mins of trying to fix, <1 minute of fixing.

  • Remove From My Forums
  • Question

  • I just installed the community version of VS 2019. I selected to build a console application that it created for me («hello world» program). The file created is called ConsoleApplication1.cpp. I went to the build menu, selected build, and get the
    following error:

    1>—— Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ——

    1>C:Program Files (x86)Microsoft Visual Studio2019CommunityMSBuildMicrosoftVCv160Microsoft.CppBuild.targets(441,5): warning MSB8003: The WindowsSDKDir property is not defined. Some build tools may not be found.

    1>ConsoleApplication1.cpp

    1>C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.24.28314includeyvals.h(12,10): fatal error C1083: Cannot open include file: ‘crtdbg.h’: No such file or directory

    1>Done building project «ConsoleApplication1.vcxproj» — FAILED.

    I tried to follow directions I saw on stackexchange. When I select «Project -> Properties» the Windows SDK field is blank. A value I typed in from another StackExchange message creates an error that that version of the SDK cannot be found. So
    I made the SDK field blank again. I also tried using «10.0», but that did nothing.

    Perhaps I did not install all the needed components. I recently checked off: «Windows Universal CRT SDK» (as per something I saw on stackexchange), but the build still fails. The warning is interesting. I looked that up also but have not found
    a solution that works. My «Platform Toolset» is Visual Studio 2019 (v142).

    What might still be missing to build a console application? Thank you. I am working on Windows 7.

  • Remove From My Forums
  • Вопрос

  • I am new to C++ programming in Visual Studio, When I run any c++ program it shows too many build errors. I am using Visual Studio Community 2015. It shows — fatal error C1083: Cannot open include file: ‘stdio.h’: No
    such file or directory

Ответы

  • I am new to C++ programming in Visual Studio, When I run any c++ program it shows too many build errors. I am using Visual Studio Community 2015. It shows — fatal error C1083: Cannot open include file: ‘stdio.h’:
    No such file or directory

    Hi,

    According to your description. The compiler generates the c1083 error when it can’t find file. There are some reasons why the compiler generates this
    error. You can see the article. Hope the article can help you to resolve the problem.

    https://msdn.microsoft.com/en-us/library/et4zwx34.aspx?f=255&MSPPError=-2147217396

    If your original problem has been resolved, please mark the thread.

    Best Regards,

    Hart

    • Помечено в качестве ответа

      12 июля 2017 г. 2:01

    • Снята пометка об ответе
      Rajat Maurya
      12 июля 2017 г. 2:02
    • Помечено в качестве ответа
      Rajat Maurya
      12 июля 2017 г. 2:03

I was beginning to use Visual Studio 2013 to work with OpenCV.

I had completed a simple project that I need and was just doing some cleanup.
The compiler begin giving the message.

error C1083: Cannot open source file:

What I have tried so far:

Creating a new console application in a separate file and trying to compile it, just created . -> same error.

Repairing Visual Studio using the original installation disk. -> same result on new just created project «error c1083;

Uninstalling Visual Studio and then reinstalling it. -> same result on new just created project «error c1083»

Things I have noticed. My compiler is not creating a .pch file or at least I cannot find it. I have precompiled headers enabled. /Yc for stdafx.cpp and /Yu. for other files if I have any.

If I use a previously created project that was working the IDE will run it, but if I change anything in the source file I get the same error.

I have tried placing projects in very short paths and in the normal location for the compiler.

Solution explorer sees and will open the source file.

I am beginning to think something is corrupted in my operating system. (Windows 7).
I have been thinking I might format the disk and reinstall Windows, but thought I might ask for suggestions on this problem first.

«
What do you mean by ‘doing some cleanup’? It is quite unlikely that your OS is corrupted. There is probably something wrong with your project properties, but I couldn’t tell you what without better information»

This was just a simple project to place cross hairs on the input from a USB microscope which was spindle mounted on a CNC milling machine for centering purposes. I was just changing the on screen position and size of the cross hairs. Then when I recompiled the problem started. I thought it might be a corrupted file because of the fact that it persisted after uninstalling and reinstalling Visual Studio. The fact that a freshly generated project would not compile made me suspicious.

«
Looks like something in your Project/Properties is not right. It is looking for the files in the wrong directory»

You are probably correct, but I am a novice and have spent many hours trying to find what it may be any suggestions for what settings to change would be greatly appreciated.

«
Do your TMP and TEMP environment variables point to directories that (1) exist (2) you have write permission to and (3) have free space? «

Yes sir The environment variables are set and the directory has read write permission. There is > 1T of free disk space.

«
Also try (with VS closed) deleting the registry keys HKCUSoftwareMicrosoftVisualStudio12.0 and 12.0_Config and the directory %LOCALAPPDATA%MicrosoftVisualStudio12.0, then open VS and try again with a fresh project. This will cause VS to regenerate all caches and «transient» information (it will also reset all your settings, so beware).»

Sir: I deleted the keys and the directory you recommended, generated a fresh project and tried to compile it. The compiler generated the same error. I genuinely appreciate the suggestion.

«VS only allows closed source development»

Pointed, consider the source of VS.

Возможно, вам также будет интересно:

  • Visual studio ошибка 1168
  • Visual studio окно ошибок как открыть
  • Visual studio не подчеркивает ошибки
  • Visual studio как отключить ошибку
  • Visual studio как включить отображение ошибок

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

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