Hi Lslkaiaoqlaoaoa,
Welcome to MSDN forum.
According to your description, I might need to confirm some information from you. Which version of Visual Studio do you use? When did your issue appear, for example, change to use other version of operating system or maybe just create a new project after
installing VS? Which version of Windows system do you use?
I suggest you could refer to below steps to try to troubleshoot this issue.
#1. Try to reset Visual C++ settings.
Please open Visual Studio -> Tools -> Import and Export Settings… -> select
Reset all settings -> Next -> choose “No, just reset settings, overwriting my current settings” -> select
Visual C++ -> Finish
#2. Try to choose a corresponding Windows SDK version.
Please open your C++ project -> right-click your project ->
Properties -> Configuration Properties ->
General -> Windows SDK Version -> choose the corresponding version of your computer’s operating system.(like 10.0 latest installed version)
#3. Try to refresh VC++ Executable Directories.
Please open your C++ project -> right-click your project ->
Properties -> Configuration Properties -> VC++ Directories -> Executable Directories -> click on the drop down and select “Edit” ->
Uncheck “Inherit from parent or project defaults” ->
Check “Inherit from parent or project defaults” again -> OK ->
Rebuild the project -> close and restart VS to check if this issue could be solved.
#4. Try to make configuration of platform consistent.
Please check the configuration and platform of your Visual Studio from standard menu and open Properties Window of your project like #2 or #3, then on the top of the Property Page make the Configuration and Platform corresponding to your standard menu setting.
#5. Try to unload project and then reload project.
Please right-click your project and choose Unload Project -> right-click and then choose
Reload Project –> Rebuild Project and check if it could work this time.
#6. Try to repair Visual Studio.
Not sure which version of VS do you use. If you use VS 2017 or higher version of VS(like 2019), please open Visual Studio Installer -> find Visual Studio that the version you use ->
More -> Repair. If you use VS 2015 or lower version of VS, please open
Control Panel -> Programs -> Uninstall a program -> find Microsoft Visual Studio 20XX -> right-click it ->
Change -> Repair.
In addition, you could try to create a new C++ project and check if the newly created solution(project) could work well.
Hope all above could help you and any feedback would be great expected.
Best Regards,
Tianyu
MSDN Community Support
Please remember to click «Mark as Answer» the responses that resolved your issue, and to click «Unmark as Answer» if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.
-
Edited by
Monday, October 28, 2019 6:47 AM
|
1 / 1 / 0 Регистрация: 01.02.2020 Сообщений: 14 |
|
|
1 |
|
|
15.02.2020, 16:22. Показов 16094. Ответов 21
Создаю консольное приложение в VS 2019, пишу ВЫШЕ исострима #include «pch.h» он выдаёт ошибку. В исходных файлах библиотеки тоже нету. Как добавить или исправить. Пол интернета перешерстил ничего не нашёл
__________________
0 |
|
194 / 151 / 44 Регистрация: 11.11.2019 Сообщений: 345 |
|
|
15.02.2020, 16:44 |
2 |
|
Вы можете отключить использование Precompiled Headers в свойствах проекта (Alt+F7). Вместо Use нужно поставить Not using… Миниатюры
0 |
|
«C with Classes» 1610 / 1383 / 518 Регистрация: 16.08.2014 Сообщений: 5,750 Записей в блоге: 1 |
|
|
15.02.2020, 16:45 |
3 |
|
пишу ВЫШЕ исострима #include «pch.h» попробуй не писать, если проект создан без опции предкомпилированных заголовочных фалов, тогда pch.h файл не нужно включать.
0 |
|
6574 / 4559 / 1843 Регистрация: 07.05.2019 Сообщений: 13,726 |
|
|
15.02.2020, 16:45 |
4 |
|
Создаю консольное приложение в VS 2019, пишу ВЫШЕ исострима #include «pch.h» он выдаёт ошибку. Просто не пиши #include «pch.h» и всё. Зачем он тебе?
0 |
|
1 / 1 / 0 Регистрация: 01.02.2020 Сообщений: 14 |
|
|
15.02.2020, 16:53 [ТС] |
5 |
|
Тогда он пишет ошибку С1010 непредвиденный конец файла во время поиска предкомпилированного заголовка. Возможно, вы забыли добавить директиву «#include «pch.h»» в источник. Когда добавляю, он пишет ранее указанную ошибку. Просто напишите, как его добавить, чтобы при создании консольного приложения он был в исходный файлах
0 |
|
6574 / 4559 / 1843 Регистрация: 07.05.2019 Сообщений: 13,726 |
|
|
15.02.2020, 17:03 |
6 |
|
Тогда он пишет ошибку С1010 непредвиденный конец файла во время поиска предкомпилированного заголовка. Возможно, вы забыли добавить директиву «#include «pch.h»» в источник. Когда добавляю, он пишет ранее указанную ошибку. Просто напишите, как его добавить, чтобы при создании консольного приложения он был в исходный файлах Проще отключить. Для начала сделай то, что написал fao, если не поможет, посмотри свойства cpp-файла и поставь No в Precompiled Header. Добавлено через 31 секунду
0 |
|
1 / 1 / 0 Регистрация: 01.02.2020 Сообщений: 14 |
|
|
15.02.2020, 17:04 [ТС] |
7 |
|
я всё это уже делал, напиши КАК ВКЛЮЧИТЬ pch.h в консольное приложение при создании. Я у кого не смотрю созданные проги, в исходных файлах есть pch.h, у меня нету
0 |
|
6574 / 4559 / 1843 Регистрация: 07.05.2019 Сообщений: 13,726 |
|
|
15.02.2020, 17:08 |
8 |
|
я всё это уже делал, напиши КАК ВКЛЮЧИТЬ pch.h в консольное приложение при создании. Я у кого не смотрю созданные проги, в исходных файлах есть pch.h, у меня нету Создай файлы pch.h и pch.cpp. В pch.cpp сделай #include «pch.h». Потом в свойствах pch.cpp установи Precompiled Header = Create
0 |
|
1 / 1 / 0 Регистрация: 01.02.2020 Сообщений: 14 |
|
|
15.02.2020, 17:10 [ТС] |
9 |
|
где создать
1 |
|
6574 / 4559 / 1843 Регистрация: 07.05.2019 Сообщений: 13,726 |
|
|
15.02.2020, 17:15 |
10 |
|
где создать File->New->File…
1 |
|
1 / 1 / 0 Регистрация: 01.02.2020 Сообщений: 14 |
|
|
15.02.2020, 18:25 [ТС] |
11 |
|
В том та и прикол, что я так делаю, он мне выдаёт эту ошибку, поэтому я и спрашиваю
0 |
|
6574 / 4559 / 1843 Регистрация: 07.05.2019 Сообщений: 13,726 |
|
|
15.02.2020, 18:30 |
12 |
|
В том та и прикол, что я так делаю, он мне выдаёт эту ошибку, поэтому я и спрашиваю Очевидно, что что-то ты делаешь не так. Тебе здесь вроде всё расписали, что нужно сделать. Предлагаешь поугадывать, где ты косячишь?
0 |
|
1550 / 875 / 179 Регистрация: 05.12.2015 Сообщений: 2,555 |
|
|
15.02.2020, 18:35 |
13 |
|
В том та и прикол, что я так делаю Зачем? Что вы хотите получить от этого файла? Чтоб было как у всех? Вам несколько раз написали, что на данном этапе обучения, вам предварительно откомпилированные заголовки на хрен не нужны. Когда они вам понадобятся, добавить их использование в проект не составит для вас никаких проблем. А сейчас, если пытаетесь откомпилировать чужой код, состоящий из одного файла, просто удалите строку #include «pch.h». Она вам не нужна.
0 |
|
1 / 1 / 0 Регистрация: 01.02.2020 Сообщений: 14 |
|
|
15.02.2020, 18:36 [ТС] |
14 |
|
Смотри, я создаю консольное приложение, в исходный файлах только название проги, в самой исострим, если я туда вписываю пцш, он выдаёт ошибку, если я запускаю другую прогу, где он был, выдаёт ту же ошибку.
0 |
|
6574 / 4559 / 1843 Регистрация: 07.05.2019 Сообщений: 13,726 |
|
|
15.02.2020, 18:38 |
15 |
|
Смотри, я создаю консольное приложение, в исходный файлах только название проги, в самой исострим, если я туда вписываю пцш, он выдаёт ошибку, если я запускаю другую прогу, где он был, выдаёт ту же ошибку. А если не вписываешь и не запускаешь другую прогу, то что?
0 |
|
194 / 151 / 44 Регистрация: 11.11.2019 Сообщений: 345 |
|
|
15.02.2020, 18:40 |
16 |
|
Я у кого не смотрю созданные проги, в исходных файлах есть pch.h, у меня нету Посмотрите сюда: https://docs.microsoft.com/en-… ew=vs-2019.
0 |
|
1550 / 875 / 179 Регистрация: 05.12.2015 Сообщений: 2,555 |
|
|
15.02.2020, 18:44 |
17 |
|
в исходный файлах только название проги, в самой исострим, если я туда вписываю пцш, он выдаёт ошибку, не вписывайте.
если я запускаю другую прогу, где он был, выдаёт ту же ошибку. Удалите строчку #include «pch.h» Какгрится, на все случаи жизни.
0 |
|
365 / 307 / 64 Регистрация: 14.10.2014 Сообщений: 1,287 |
|
|
15.02.2020, 20:50 |
18 |
|
fao, Вся эта «предкомпилированная хреновина» отключается на раз в настройках проекта, как — вам уже сообщили . После — нужно удалить файлы из проекта (ручками жмём на них правой кнопкой и выбираем удалить)Но если и с этим возникли трудности — остаётся последнее — создать новый пустой проект — создать в нем файл с исходниками и скопировать в него текст из не запускаемого проекта, естественно без #include «pch.h»
0 |
|
194 / 151 / 44 Регистрация: 11.11.2019 Сообщений: 345 |
|
|
15.02.2020, 21:18 |
19 |
|
fao, Вся эта «предкомпилированная хреновина» отключается на раз в настройках проекта Дык я и так в курсе
0 |
|
1550 / 875 / 179 Регистрация: 05.12.2015 Сообщений: 2,555 |
|
|
15.02.2020, 21:25 |
20 |
|
fao, видимо, Recrut_rf fao с fl0op перепутал. Но, ничего. Главное, что любой эрудированный человек отличит Гоголя от Гегеля, Гегеля от Бебеля, Бебеля от Бабеля, Бабеля от кабеля, кабеля от кобеля, кобеля от сучки.
0 |
So I recently downloaded Windows Visual Studio 2019. I haven’t programmed in a while and I wanted to refresh myself with a basic «hello world» program. But for some reason I’m getting an error with my Stdafx.h header. The error code is E1696 «cannot open source file «stdafx.h»» anyone know how to fix it?
asked Aug 11, 2019 at 5:12
![]()
The default precompiled header in Visual Studio used to be stdafx.h. Since then, the default name has been changed to pch.h, and later precompiled headers became disabled by default. Simply remove the #include "stdafx.h" or change it to #include "pch.h" depending on your precompiled header settings. If you don’t need precompiled headers, you can disable it.
answered Aug 11, 2019 at 5:28
eesiraedeesiraed
4,6084 gold badges16 silver badges34 bronze badges
1
Hi Lslkaiaoqlaoaoa,
Welcome to MSDN forum.
According to your description, I might need to confirm some information from you. Which version of Visual Studio do you use? When did your issue appear, for example, change to use other version of operating system or maybe just create a new project after
installing VS? Which version of Windows system do you use?
I suggest you could refer to below steps to try to troubleshoot this issue.
#1. Try to reset Visual C++ settings.
Please open Visual Studio -> Tools -> Import and Export Settings… -> select
Reset all settings -> Next -> choose “No, just reset settings, overwriting my current settings” -> select
Visual C++ -> Finish
#2. Try to choose a corresponding Windows SDK version.
Please open your C++ project -> right-click your project ->
Properties -> Configuration Properties ->
General -> Windows SDK Version -> choose the corresponding version of your computer’s operating system.(like 10.0 latest installed version)
#3. Try to refresh VC++ Executable Directories.
Please open your C++ project -> right-click your project ->
Properties -> Configuration Properties -> VC++ Directories -> Executable Directories -> click on the drop down and select “Edit” ->
Uncheck “Inherit from parent or project defaults” ->
Check “Inherit from parent or project defaults” again -> OK ->
Rebuild the project -> close and restart VS to check if this issue could be solved.
#4. Try to make configuration of platform consistent.
Please check the configuration and platform of your Visual Studio from standard menu and open Properties Window of your project like #2 or #3, then on the top of the Property Page make the Configuration and Platform corresponding to your standard menu setting.
#5. Try to unload project and then reload project.
Please right-click your project and choose Unload Project -> right-click and then choose
Reload Project –> Rebuild Project and check if it could work this time.
#6. Try to repair Visual Studio.
Not sure which version of VS do you use. If you use VS 2017 or higher version of VS(like 2019), please open Visual Studio Installer -> find Visual Studio that the version you use ->
More -> Repair. If you use VS 2015 or lower version of VS, please open
Control Panel -> Programs -> Uninstall a program -> find Microsoft Visual Studio 20XX -> right-click it ->
Change -> Repair.
In addition, you could try to create a new C++ project and check if the newly created solution(project) could work well.
Hope all above could help you and any feedback would be great expected.
Best Regards,
Tianyu
MSDN Community Support
Please remember to click «Mark as Answer» the responses that resolved your issue, and to click «Unmark as Answer» if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.
-
Edited by
Monday, October 28, 2019 6:47 AM
Hi Lslkaiaoqlaoaoa,
Welcome to MSDN forum.
According to your description, I might need to confirm some information from you. Which version of Visual Studio do you use? When did your issue appear, for example, change to use other version of operating system or maybe just create a new project after
installing VS? Which version of Windows system do you use?
I suggest you could refer to below steps to try to troubleshoot this issue.
#1. Try to reset Visual C++ settings.
Please open Visual Studio -> Tools -> Import and Export Settings… -> select
Reset all settings -> Next -> choose “No, just reset settings, overwriting my current settings” -> select
Visual C++ -> Finish
#2. Try to choose a corresponding Windows SDK version.
Please open your C++ project -> right-click your project ->
Properties -> Configuration Properties ->
General -> Windows SDK Version -> choose the corresponding version of your computer’s operating system.(like 10.0 latest installed version)
#3. Try to refresh VC++ Executable Directories.
Please open your C++ project -> right-click your project ->
Properties -> Configuration Properties -> VC++ Directories -> Executable Directories -> click on the drop down and select “Edit” ->
Uncheck “Inherit from parent or project defaults” ->
Check “Inherit from parent or project defaults” again -> OK ->
Rebuild the project -> close and restart VS to check if this issue could be solved.
#4. Try to make configuration of platform consistent.
Please check the configuration and platform of your Visual Studio from standard menu and open Properties Window of your project like #2 or #3, then on the top of the Property Page make the Configuration and Platform corresponding to your standard menu setting.
#5. Try to unload project and then reload project.
Please right-click your project and choose Unload Project -> right-click and then choose
Reload Project –> Rebuild Project and check if it could work this time.
#6. Try to repair Visual Studio.
Not sure which version of VS do you use. If you use VS 2017 or higher version of VS(like 2019), please open Visual Studio Installer -> find Visual Studio that the version you use ->
More -> Repair. If you use VS 2015 or lower version of VS, please open
Control Panel -> Programs -> Uninstall a program -> find Microsoft Visual Studio 20XX -> right-click it ->
Change -> Repair.
In addition, you could try to create a new C++ project and check if the newly created solution(project) could work well.
Hope all above could help you and any feedback would be great expected.
Best Regards,
Tianyu
MSDN Community Support
Please remember to click «Mark as Answer» the responses that resolved your issue, and to click «Unmark as Answer» if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.
-
Edited by
Monday, October 28, 2019 6:47 AM
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Closed
jessekirbs opened this issue
Jun 17, 2020
· 3 comments
Assignees
Labels
Bug
Something isn’t working
Code Sample
This issue is related to a code sample
Comments
When trying to build ALL_BUILD in the green screen project within Visual Studio 2019, I get the following error:
Error (active) E1696 cannot open source file "k4a/k4a.hpp"
I’ve tried:
- Installing the Kinect Azure libraries via NuGet
- Including a k4a folder in the project root with k4a.hpp inside,
- Right clicking ALL_BUILD → Properties → Configuration Properties → VC++ Directories and adding the path to k4a.hpp under Include Directories.
To Reproduce
- Use CMake GUI to configure and generate project files.
- Open Project.sln
- Right click ALL_BUILD in Solution Explorer
- Click Build
- Error appears in Error List
Desktop:
- Windows 10 Version 1909 for x64
- Azure Kinect SDK v1.4.0
qm13
removed
the
Triage Needed
The Issue still needs to be reviewed by Azure Kinect team members.
label
Jun 18, 2020
I was able to solve this issue by:
-
Using git to clone the repository with:
git clone https://github.com/microsoft/Azure-Kinect-Sensor-SDK.git -
Copying ‘depthengine_2_0.dll’ from the path …Azure Kinect SDK v1.4.0sdkwindows-desktopamd64releasebin to my self-compiled ‘bin’ folder.
-
Move the contents of the …binDebug folder into the bin folder
-
Run executable.
@jessekirbs I’m running into the same issue. What do you mean by self-compiled ‘bin’ folder in the above comment?
@srinivas-varadharajan The bin folder that was created after running Generate in CMAKE. So:
-
Use git to clone the repository with:
git clone https://github.com/microsoft/Azure-Kinect-Sensor-SDK.git -
Run CMAKE and generate project files.
-
Open K4A.sln in Visual Studio
-
Build all.
-
Copy ‘depthengine_2_0.dll’ from the path …Azure Kinect SDK v1.4.0sdkwindows-desktopamd64releasebin to the ‘bin’ folder generated from CMAKE.
-
Move all files from the CMAKE generated …binDebug folder up one level to the ‘bin’ directory.
-
Run whatever .exe
Let me know if that makes sense and if it works for you. Otherwise, I can try to help.
Labels
Bug
Something isn’t working
Code Sample
This issue is related to a code sample
In c++ project when you have included header file, but inside project we are not able to access that header file then generally we get error for cannot open source file. For fixing this error check that included file is available in project include path or not.
cannot open source file visual studio C++
Solution-1 : Check your Visual Studio Project settings under C++, Check Include directories and make sure Your_filename.h is pointing to correct path. After adding proper include directories it will resolve cannot open source file visual studio error.

You can right click to header file and open from visual studio. If file is pointing properly it will open.

If your include file is not properly pointing or you have not added inside your included directory then you will not able to open from visual studio.

Solution-2 : Another solution, If your header file is at different folder/location then you can include file path directly in header file. Here you can use relative path or you can provide full path of header file.
Include based on your project folder structure and requirement.
#include "../FolderName/filename.h" OR #include "./FolderName/filename.h" OR #include "FullPath/filename.h"
Solution-1: iostream file opening error normally comes when we are missing $(IncludePath) inside Properties->VC++ Directories->Include Directories. And you have by mistake removed Include path.
Solution-2: Other possible reason is that during installing Visual studio you did not selected c++ packages.
Solution-3: You can check by including stdafx.h in starting (only for Visual studio projects)
#include "stdafx.h" #include <iostream> using namespace std;
Solution-4: Sometimes these type of error comes when multiple Visual Studio versions are install in single PC. You can check Projects and Solutions –> VC++ Directories, are properly added for your project and pointing to correct version location.
For Visual Studio Code:
c++ cannot open source file iostream in visual studio code can also occurs when proper paths are not added inside visual studio code c_cpp_properties.json file.
Mode details:
https://code.visualstudio.com/docs/cpp/config-msvc#_prerequisites
cannot open source file “string”
Try below steps to resolve error.
1) Open VC++ Directories option inside Configuration Properties of visual studio
2) Her all directories value (e.g. Executable directories) will be available, just you need to select drop-down and click edit
3) Remove selection of Inherit from parent
4) Now just click OK and you will see no changes inside Edit box.
5) You need to repeat this thing for all directories, At the end executable directories will be set to $(ExecutablePath) and Include directories will be set to $(IncludePath), similar way to all directories
6)Now click apply and then OK
Conclusion for cannot open source file c++
We have provided solutions for multiple errors for can not open source file c++, If you try given solution hopefully you will able to resolve error. But if still you are getting error you can add your comment and code. We will try to resolve and find solution for you. Happy coding 🙂
Reader Interactions
#c #header #visual-studio-2019 #precompiled-headers #stdafx.h
#c #заголовок #visual-studio-2019 #предварительно скомпилированные заголовки #stdafx.h
Вопрос:
У меня есть два проекта A и B. В проекте A я создал исходный файл с именем Logger.cpp где у меня есть #include «stdafx.h» в части includes. Файл stdafx.h присутствует в проекте A. В свойствах проекта A у меня есть расположения заголовочных файлов проекта B в свойстве «Дополнительные каталоги включения». Когда я пытаюсь скомпилировать решение в Visual Studio 2013, оно успешно компилируется, но когда я пытаюсь перенести свое решение в Visual Studio 2019 и скомпилировать все решение или только проект A, я получаю сообщение об ошибке E1696 не удается открыть исходный файл «stdafx.h».
Что я пробовал:
- Я скопировал файл stdafx.h из проекта A в проект B, что приводит к конфликтам и не позволяет мне открывать какие-либо заголовочные файлы, включенные в файл stdafx.h.
- Я полностью удалил проект A, а затем создал новый проект C , поскольку файл stdafx.h создается при создании нового проекта.
Оба вышеуказанных подхода не решают проблему.
Я что-то здесь упускаю?
Ответ №1:
Согласно документам Microsoft, при создании нового проекта в Visual Studio в проект добавляется предварительно скомпилированный заголовочный файл с именем pch.h. (В Visual Studio 2017 и более ранних версиях файл назывался stdafx.h.)
Итак, вы могли бы установить stdafx.h Properties->C/C ->Precompiled Header->Precompiled Header file .


