Sometimes I write small programs, but I don't want to start 2013, and vscode has become my first choice. When I first came into contact with vscode, I configured a bunch of things online, and finally I could compile C/C++, but when multiple files were involved, I had to open vs2013 obediently. When I was configuring vscode on Linux a few days ago, I suddenly found that the command of some netizens in tasks.json was make, and I suddenly became interested. I thought that since make is used, I only need a makefile, and then Ctrl+Shift+B, in Can't the problem of multi-file compilation and connection on vscode be solved? So I started to write tasks.json according to the configuration of the netizen. But in the end, the make command failed to execute, saying that the target could not be found (forgot), but I was not reconciled, so Baidu and google searched for almost two hours without finding an effective solution.
When I looked at my configuration carefully again, when the cursor moved to the command, a prompt " The command to be executed. Can be an external program or a shell command. " appeared. I felt like vomiting blood when I saw that shell commands were also available. I felt like I wasted two precious hours. Obviously, it became very simple to use shell scripts. How simple? look at the picture
tasks.json
.make.sh
Simple, just pass the file directory ${fileDirName} as a parameter to .make.sh through vscode. After entering this directory in the script, make it again.
The following tests pass
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
Ctrl+Shift+B前
Ctrl+Shift+B后
debug
At this point, the vscode configuration on Linux is complete. In Windows, it is good to write a simple batch process in the same way, but first, you need to install and configure the gcc/g++ environment for mingw32. In addition, there is no make.exe under the bin of mingw32. But there is a mingw32-make.exe, just change it to make, or not, but write mingw32-make instead of make in the corresponding batch file, not much to say, paste the configuration diagram of windows
Finally, post my makefile and launch.json by the way
Linux under makefile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Linux下launch.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
Under Windows makefile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Windows下launch.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|