Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution that vscode can not find the C++ header file under windows

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail about windows vscode can not find c++ header file solution, Xiaobian think quite practical, so share to everyone as a reference, I hope you can read this article after harvest.

The problem with vscode not finding header files is that the default compiler for vscode under windows is Microsoft MSVC(vs the compiler used) header file path.

If you don't install vs, you will definitely report an error because you can't find the header file. If you install vs, you will also report an error. The reasons are as follows:

1. You misconfigured the vscode configuration file;

2. You used header files that do not exist in MSVC header library, such as bits/stdc++.h

Solution:

1. Modify the configuration file;

2. Copy the required header file to the vs header file path

If the computer does not have vs installed and mingw series installed, it can only be solved by modifying the configuration file.

1. How to modify the configuration file:

Create a new c_cpp_properties.json file in the.vscode folder

Paste the following code into it. where you want to change the includePath option to the lib/gcc/x86_64-w64-mingw32/8.1.0/include folder path under your mingw compiler installation path

{ "configurations": [ { "name": "Win32", "includePath": [ "C:/Program Files/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "intelliSenseMode": "gcc-x64" } ], "version": 4}

For header files in non-standard libraries, the path can also be appended to includePath by list appending.

For example:

Second, the method of modifying the header file:

First you must install one of the Microsoft vs series, such as visual stdio 2017 Community, and then find the header file path under the installation path

The default is:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include

Then paste the header files you need into this folder so MSVC and mingw have the same header library.

About "windows vscode can not find c++ header file solution" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report