VS Code Makefile Tools扩展:如何将当前目录设为Makefile路径?
VS Code Makefile Tools扩展路径设置问题解决
指定Makefile路径的正确方式
完全可以通过makefile.makefilePath指定任意位置的Makefile,不管是当前目录还是其他目录:- 如果Makefile在VS Code打开的工作区根目录,直接设置为
"makefile.makefilePath": "Makefile"或者"./Makefile"即可; - 如果在子目录(比如
src文件夹),写相对路径:"makefile.makefilePath": "src/Makefile"; - 如果在上级目录或其他绝对路径位置,直接写绝对路径,比如Linux/macOS下
"/home/user/projects/Makefile",Windows下"C:\\projects\\Makefile"。
- 如果Makefile在VS Code打开的工作区根目录,直接设置为
修正你的settings.json语法错误
你的配置文件存在两处语法问题,会导致VS Code无法正确加载配置:makefile.makefilePath后面没有赋值,也缺少逗号;interactiveWindow.alwaysScrollOnNewCell后面没有赋值,且最后一个键值对不需要逗号。
修正后的示例(假设你要指定当前工作区根目录的Makefile):
{ "workbench.layoutControl.enabled": true, "workbench.layoutControl.type": "toggles", "workbench.startupEditor": "none", "settingsSync.ignoredSettings": [], "workbench.iconTheme": "material-icon-theme", "C_Cpp.errorSquiggles": "Enabled", "workbench.tree.indent": 30, "makefile.loggingLevel": "Verbose", "terminal.integrated.copyOnSelection": true, "terminal.integrated.cursorBlinking": true, "terminal.integrated.cursorStyle": "line", "terminal.integrated.defaultLocation": "terminal", "terminal.integrated.fontFamily": "monospace", "editor.fontFamily": "Ubuntu Mono", "C_Cpp.experimentalFeatures": "Enabled", "window.title": "File Name: '${activeEditorLong}' | Path: ${folderPath} | Status: ${dirty}", "makefile.launchConfigurations": [], "makefile.makefilePath": "./Makefile", "material-icon-theme.folders.color": "#F1D592", "makefile.panel.visibility": true, "interactiveWindow.alwaysScrollOnNewCell": true }额外建议
推荐使用工作区设置(即项目根目录下的.vscode/settings.json)来配置makefile.makefilePath,而不是全局设置,这样不同项目可以有独立的配置,不会互相干扰。
内容的提问来源于stack exchange,提问作者amc48
相关产品推荐
相关产品推荐

