我已经在我的 64 位 win10 上安装了 Microsoft Visual C++ Build Tools 2015,并且可以使用 cl.exe 通过以下步骤在普通的命令提示符窗口中编译和链接 C/C++ 程序(来自设置路径和环境的一些说明命令行构建的变量):
1. cd "\Program Files (x86)\Microsoft Visual Studio 14.0\VC"
2. vcvarsall amd64
3. cl helloworld.c
helloworld.c 只是一个简单的 C 源文件,用于打印“Hello world!”。我还尝试将task.json配置为直接编译和链接vs代码中的C/C++程序。这是我的task.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "vcvarsall amd64 && cl",
"isShellCommand": true,
"args": ["${file}"],
"showOutput": "always"
}
并且PATH 中已经添加了 和 的路径vsvarsall
。cl
但它仍然不起作用(输出放在帖子的末尾)。所以我的问题是:我如何定义task.json,它可以先运行vcvarsall amd64
设置系统变量,然后执行cl
命令来编译和链接程序。