Меню

Ошибка e1696 c visual studio 2019

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…
Тогда при компиляции VS не будет искать файл «pch.h»

Миниатюры

E1696 не удается открыть источник файл pch.h
 



0



«C with Classes»

1610 / 1383 / 518

Регистрация: 16.08.2014

Сообщений: 5,750

Записей в блоге: 1

15.02.2020, 16:45

3

Цитата
Сообщение от fl0op
Посмотреть сообщение

пишу ВЫШЕ исострима #include «pch.h»

попробуй не писать, если проект создан без опции предкомпилированных заголовочных фалов, тогда pch.h файл не нужно включать.



0



6574 / 4559 / 1843

Регистрация: 07.05.2019

Сообщений: 13,726

15.02.2020, 16:45

4

Цитата
Сообщение от fl0op
Посмотреть сообщение

Создаю консольное приложение в 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

Цитата
Сообщение от fl0op
Посмотреть сообщение

Тогда он пишет ошибку С1010 непредвиденный конец файла во время поиска предкомпилированного заголовка. Возможно, вы забыли добавить директиву «#include «pch.h»» в источник. Когда добавляю, он пишет ранее указанную ошибку. Просто напишите, как его добавить, чтобы при создании консольного приложения он был в исходный файлах

Проще отключить. Для начала сделай то, что написал fao, если не поможет, посмотри свойства cpp-файла и поставь No в Precompiled Header.

Добавлено через 31 секунду
И смотри, чтоб Configuration была нужная



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

Цитата
Сообщение от fl0op
Посмотреть сообщение

я всё это уже делал, напиши КАК ВКЛЮЧИТЬ 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

Цитата
Сообщение от fl0op
Посмотреть сообщение

где создать

File->New->File…
Я тебе ещё раз повторяю — если этого pch.h нет после создания проекта (а в Console Application его нет), значит он нахрен там не нужен, т.е. ты что-то наковырял уже сам. Просто создай новый проект и перетащи свои файлы из старого, кривого.



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

Цитата
Сообщение от fl0op
Посмотреть сообщение

В том та и прикол, что я так делаю, он мне выдаёт эту ошибку, поэтому я и спрашиваю

Очевидно, что что-то ты делаешь не так. Тебе здесь вроде всё расписали, что нужно сделать. Предлагаешь поугадывать, где ты косячишь?



0



1550 / 875 / 179

Регистрация: 05.12.2015

Сообщений: 2,555

15.02.2020, 18:35

13

Цитата
Сообщение от fl0op
Посмотреть сообщение

В том та и прикол, что я так делаю

Зачем? Что вы хотите получить от этого файла? Чтоб было как у всех? Вам несколько раз написали, что на данном этапе обучения, вам предварительно откомпилированные заголовки на хрен не нужны. Когда они вам понадобятся, добавить их использование в проект не составит для вас никаких проблем. А сейчас, если пытаетесь откомпилировать чужой код, состоящий из одного файла, просто удалите строку #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

Цитата
Сообщение от fl0op
Посмотреть сообщение

Смотри, я создаю консольное приложение, в исходный файлах только название проги, в самой исострим, если я туда вписываю пцш, он выдаёт ошибку, если я запускаю другую прогу, где он был, выдаёт ту же ошибку.

А если не вписываешь и не запускаешь другую прогу, то что?



0



194 / 151 / 44

Регистрация: 11.11.2019

Сообщений: 345

15.02.2020, 18:40

16

Цитата
Сообщение от fl0op
Посмотреть сообщение

Я у кого не смотрю созданные проги, в исходных файлах есть pch.h, у меня нету

Посмотрите сюда: https://docs.microsoft.com/en-… ew=vs-2019.
Если вы создаете проект по такому шаблону, то там не будет файла pch.h. Возможно проекты, которые вы видели созданы с использованием других шаблонов.



0



1550 / 875 / 179

Регистрация: 05.12.2015

Сообщений: 2,555

15.02.2020, 18:44

17

Цитата
Сообщение от fl0op
Посмотреть сообщение

в исходный файлах только название проги, в самой исострим, если я туда вписываю пцш, он выдаёт ошибку,

не вписывайте.

Цитата
Сообщение от oleg-m1973
Посмотреть сообщение

если я запускаю другую прогу, где он был, выдаёт ту же ошибку.

Удалите строчку #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

Цитата
Сообщение от Recrut_rf
Посмотреть сообщение

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

PringlesT-rex's user avatar

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

eesiraed's user avatar

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

@qm13

Labels

Bug

Something isn’t working

Code Sample

This issue is related to a code sample

Comments

@jessekirbs

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

  1. Use CMake GUI to configure and generate project files.
  2. Open Project.sln
  3. Right click ALL_BUILD in Solution Explorer
  4. Click Build
  5. Error appears in Error List

Desktop:

  • Windows 10 Version 1909 for x64
  • Azure Kinect SDK v1.4.0

@qm13
qm13

removed
the

Triage Needed

The Issue still needs to be reviewed by Azure Kinect team members.

label

Jun 18, 2020

@jessekirbs

I was able to solve this issue by:

  1. Using git to clone the repository with:

    git clone https://github.com/microsoft/Azure-Kinect-Sensor-SDK.git

  2. Copying ‘depthengine_2_0.dll’ from the path …Azure Kinect SDK v1.4.0sdkwindows-desktopamd64releasebin to my self-compiled ‘bin’ folder.

  3. Move the contents of the …binDebug folder into the bin folder

  4. Run executable.

@srinivas-varadharajan

@jessekirbs I’m running into the same issue. What do you mean by self-compiled ‘bin’ folder in the above comment?

@jessekirbs

@srinivas-varadharajan The bin folder that was created after running Generate in CMAKE. So:

  1. Use git to clone the repository with:
    git clone https://github.com/microsoft/Azure-Kinect-Sensor-SDK.git

  2. Run CMAKE and generate project files.

  3. Open K4A.sln in Visual Studio

  4. Build all.

  5. Copy ‘depthengine_2_0.dll’ from the path …Azure Kinect SDK v1.4.0sdkwindows-desktopamd64releasebin to the ‘bin’ folder generated from CMAKE.

  6. Move all files from the CMAKE generated …binDebug folder up one level to the ‘bin’ directory.

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

visual studio additional include directory
include directories to your header file

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

open c++ header file
Right click and try to open header file

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.

error while opening header file
if file is not included in project then give this error

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

Что я пробовал:

  1. Я скопировал файл stdafx.h из проекта A в проект B, что приводит к конфликтам и не позволяет мне открывать какие-либо заголовочные файлы, включенные в файл stdafx.h.
  2. Я полностью удалил проект 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 .

введите описание изображения здесь

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

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

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Ошибка e10 на стиральной машине midea
  • Ошибка e30 посудомоечная машина haier