Vscode configures C/C++ and reports an error, launch program does not exist | Unable to detect header file: #include error detected. Please update includePath. |Solution

Project scenario:

insert image description here
Running error:
insert image description here

insert image description here

After installing VScode, there was a problem that the header file could not be read. Later, I found that many things were not installed properly. I just took this opportunity to learn the structure of the C++ language.

solution:

First of all, one of the reasons I found out is that I didn't download MinGW.
insert image description here

MinGW is introduced as follows: MinGW is a C/C++ programming environment on the Windows platform. It provides a set of GNU tools and libraries, including GCC compiler, GDB debugger, MSYS shell, etc., which can be used to develop and compile C/C++ programs . The full name of MinGW is Minimalist GNU for Windows. Its goal is to provide an environment as small and simple as possible to facilitate programming using GNU tools on the Windows platform. MinGW can be integrated with many IDEs, such as Code::Blocks, Eclipse, etc.

Then I found the address of a blogger’s video on the Internet and downloaded it: https://www.bilibili.com/video/BV1kR4y1M7R8/?spm_id_from=333.337.search-card.all.click&vd_source=3018264d4331e8fc267f9d68c24ee20f

The downloaded MinGW looks like this:
insert image description here
in the MinGW installation directory,
the executable files provided by MinGW are stored under the bin folder, including GCC compiler, GDB debugger, make and other tools. These tools are necessary to develop and compile C/C++ programs.

Some header files (.h files) are stored under the include folder. These header files contain declarations and macro definitions of various library functions, which can be used in programs. When compiling a C/C++ program, the compiler needs to use these header files to resolve the function and variable declarations in the program in order to correctly generate the object code.

lib folder: stores the static library files (.a files) used by MinGW. These library files contain the implementation codes of various functions and variables, which can be used in the program.

share folder: store some shared data files, such as some configuration files and documents used by MinGW.

man folder: Store MinGW man page files (.man files), which contain instructions and examples for various commands and functions.

mingw32 folder: Store some system files and header files of MinGW, including Windows API header files and some MinGW-specific header files.

The contents of these folders are required by the MinGW compiler and tool chain, and together they form a complete programming environment that can be used to develop and compile C/C++ programs.


So I saw the header files I was thinking about in include:
insert image description here

Now there should be only one environment variable. The system searches for "environment variables"
insert image description here
, clicks on the environment variables and double-clicks, the path of the system variables:
insert image description here
After entering, create a new path: your own MinGW bin folder address:
insert image description here
Then create a new folder again, enter a few pieces of code, and then click f5 to run , vscode will not report an error, and the library file can also be recognized:
insert image description here
it is strange that it will not report an error if it is in a new folder, and the old folder still cannot recognize the header file

Guess you like

Origin blog.csdn.net/weixin_46274756/article/details/130975627