简体   繁体   中英

cannot open source file "crtdbg.h" (dependency of "iostream") C/C++(1696)

I am using VSCode and the code compiles just fine with the.run extension but the C/C++ extension is throwing me this error and underlining #include <iostream> as an error. And yes I have MinGW installed in my system.

Furthermore, I get the same error on visual studio community 2019, it does not execute there at all.

System: Windows 10 Version 10.0.19042 Build 19042

VSCode Version: 1.54.1

gcc version: 8.1.0

Visual Studio Community Version: 16.8.5 (Just used it to check if the problem was due to VSCode or if it was a systematic error)

Extension Showing the error: C/C++ for Visual Studio Code v1.2.2

The extension I use to run the code: Code Runner v0.11.3

  • hover on the line showing error
  • left click on the bulb, it will take you to C/C++ configurations
  • Now change complier path to C:/MinGW64/bin/g++.exe
  • on the top u will see a link c_cpp_properties.json click on it
  • in c_cpp_properties.json "intelliSenseMode": "windows-gcc-x64"

This works well.

2022 UPDATE:

answer by @Prabhat Bhargav worked for me, but I had to change path to C:/MinGW/bin/g++.exe instead of C:/MinGW64/bin/g++.exe

Guess they changed default folder name by removing 64 (at least on windows 10).

After that it worked properly. Also if you changed the default installation folder when installing MinGW compiler, you will have to select that as your compiler path.

click on include path settings. Edit your compiler path and set it to MINGW gcc.

it will solve your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM