VS Code "command":"make"与终端窗口中的命令行"make"不同
VS Code "command": "make" differs from command line `make` in terminal window
我前段时间安装了Linux版的VS Code,在工作区中打开了一个C++项目,创建了tasks.json
——总的来说,我做的一切都是按照谷歌的。
当我在终端窗口中运行make
命令时,一切都很好。但当我在VS Code中执行同样的操作(Ctrl+Shift+B(时,我会得到一个错误。
在命令libtool: link: c++ -fPIC -DPIC -shared -nostdlib /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu/crti.o ....
之后,处理我的Makefile
终止
带有消息c++: error: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.3.0/../../../x86_64-linux-gnu/crti.o: No such file or directory
。
当然,路径是正确的(当我在终端窗口中使用命令行make
时,路径是好的(。
tasks.json
的内容很琐碎(与microsoft.com相同(:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "ClanLib",
"type": "shell",
"command": "make",
// start the build without prompting for task selection, use "group": "build" otherwise
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
},
// arg passing example: in this case is executed make QUIET=0
"args": ["QUIET=0"],
// Use the standard less compilation problem matcher.
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["absolute"],
"pattern": {
"regexp": "^(.*):(\d+):(\d+):\s+(warning|error):\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}
我不能发布Makefile
,它由从https://github.com/sphair/ClanLib...
请帮助设置Visual Studio代码(Linux Mint(。
看起来您尝试在一个目录中手动构建makefile,并从另一个目录构建vscode。如果是这种情况,您可以使用cwd
选项-doc:告诉您的任务从特定目录运行
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "ClanLib",
"type": "shell",
"command": "make",
"options": {
"cwd": "${workspaceRoot}/<DIR_WITH_MAKEFILE>"
}
...
}]}
我好像感觉到了什么。在VSCode内部的终端窗口中,我看到
sh-4.4$ help
GNU bash, версия 4.4.19(1)-release (x86_64-unknown-linux-gnu)
但在操作系统终端:
art@artPC:~/git/ClanLib$ help
GNU bash, версия 4.4.19(1)-release (x86_64-pc-linux-gnu)
差异为-未知-和-pc-。whoami
在两个端子上的结果相同。
最后在VSCode终端:
sh-4.4$ ls
x86_64-unknown-linux-gnu
符号链路x86_64-unknown-linux-gnu
的名称在OS和VSCode之间是不同的。VSCode的错误?
解决方案在这里https://github.com/Microsoft/vscode/issues/62532
感谢@jerch 先生
您安装了不同的构建集,请参阅"GNU Make 4.1"与"GNU Mak 4.2.1"。由于某些原因,/bin/sh默认为另一个。要解决这个问题,你必须咨询发行版的帮助(在Ubuntu中,你可以使用updatealternates命令切换构建集(。
- 从命令行c++发送文本文件名
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 如何在OMNET++中指定与命令行参数组合的输出文件名
- 数组长度,为什么从命令行获取时不能使用它?
- 如何处理linux终端中带有负号(-)的C++中的命令行参数
- VS Code "command":"make"与终端窗口中的命令行"make"不同
- 未定义的引用 .. 使用 OpenCV 编译 C++ 代码时,从命令行
- 通过 Openssl 命令行加密,通过 c++ 解密
- CMake "--target install"无需"--build"命令行
- 更改命令行 qt5 源代码构建配置的正确/快速方法
- make 命令如何避免重新编译未更改的源文件?
- 使用 C++ 将命令行参数拆分为参数/向量
- 用于解析 win64 堆栈跟踪的命令行客户端(可以访问符号服务器)
- LLVM | codegen 用于带有命令行选项的程序输入功能
- 如何在OMNET++中添加专门的命令行参数?
- Makefile g++ 使用命令行中的 -D 变量进行编译,默认值
- 在命令行中创建快捷命令
- 链接从命令行转换为Make的库
- GNU MAKE - 从我自己的 Makefile 创建 getoptpp 库或建议 c++ 的命令行选项库
- eclipsecdt:从命令行调用make文件并添加版本号