Win10 installs C language or C++ development environment Cygwin64 (including gcc, g++, make, gdb and other tools) + VSCode and debugging

Development environment: Cygwin64 (including gcc, etc.) + VSCode

1. Download Cygwin64 

Link: https://pan.baidu.com/s/1V7rCuaD1akayVy30lEkcRQ Extraction code: p8pz

Open after downloading and press Enter all the way

user URL: Join http://mirrors.aliyun.com and select it, the next step.

The current cywin default is a minimal installation, but does not include Gcc. If you want to use gcc, g++, make, gdb tools, you need to choose gcc-core, gcc-g++, make, gdb, binutils five packages to download, all in Category Under Devel.

The default is Skip skip, and keep after successful installation. You need to search 5 packages such as gcc-core, select the latest stable version number, and click Next after the 5 packages are selected. Enter all the way to complete the installation.

 

Test installation results:

g ++ -v

gcc -v

2. Download VSCode official website to download and install, this is fast and simple. Install the plug-in C/C++, Chinese (Simplified) 

3. Create a simple c source code project

main.c

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
    printf("pause");
    return (0);
}

4. Compile and debug environment settings

Refer to the official website description: https://code.visualstudio.com/docs/cpp/config-mingw

First select main.c, click the menu Terminal> Configure default generation tasks> C/C++: g++.exe build active file

The task.json generated by default looks like this.

 Change only one place: the path and file name of the executable file that you want to generate, the last one of args, such as "${workspaceFolder}\\main.exe"

First select main.c, click menu Run>Add configuration>C++(GDB/LLDB)>gcc.exe-build and debug active file

Launch.json is generated by default, this does not need to be changed.

OK immediately, generate main.exe and enter debugging

It succeeded. Alas, too many pits. It is far inferior to Turbo C when learning C language.

 

vscode predefined variables

Reference https://code.visualstudio.com/docs/editor/variables-reference

${workspaceFolder}-the path of the folder opened in VS Code
$ {workspaceFolderBasename}-the name of the folder opened in VS Code without any slashes (/)
$ {file}-the currently opened file
$ {relativeFile }-The current relative to the opened file workspaceFolder
$ {relativeFileDirname}-The relative directory name of the currently opened file workspaceFolder
$ {fileBasename}-The base name of the currently opened file
$ {fileBasenameNoExtension}-The base name of the currently opened file, none File extension
${fileDirname}-the directory name of the currently opened file
$ {fileExtname}-the extension of the currently opened file
$ {cwd} -the current working directory of the task runner at startup
$ {lineNumber}-the current active file Selected line number
${selectedText}
-the currently selected text in the active file ${execPath}-the path of the running VS Code executable file
${defaultBuildTask} -the name of the default build task

Guess you like

Origin blog.csdn.net/chenhao0568/article/details/105300350