VS Code compiles multiple C++ files

We can customize the build process by modifying the tasks.json file.

  • Compile multiple C++ files: By modifying "${file}" to "${workspaceFolder}\\*.cpp", all C++ files in the current workspace can be constructed.
            "args": [
                "-g",
                "${workspaceFolder}/src/*.cpp",
                "${workspaceFolder}/FolderA/*.cpp",
                "${workspaceFolder}/FolderB/*.cpp",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
                "-lpthread",
                "-lrt"
            ],
  • Modify the file name of the compiled output: by changing "${fileDirname}\\${fileBasenameNoExtension}.exe" to "${workspaceFolder}\\myProgram.exe", the file name of the compiled output can be changed to myProgram, and It is not the same name as the C++ file.

 

Guess you like

Origin blog.csdn.net/qingzhuyuxian/article/details/107446357