我创建了一个文件D:\Program\USACO\[C2, S3.2] Magic Square.cpp
但是当我编译时
发生一些错误:
[Running] cd "d:\Program\USACO\" && g++ [C2, S3.2] Magic Square.cpp -o [C2, S3.2] Magic Square && "d:\Program\USACO\"[C2, S3.2] Magic Square
g++: error: [C2,: No such file or directory
g++: error: S3.2]: No such file or directory
g++: error: Magic: No such file or directory
g++: error: Square.cpp: No such file or directory
g++: error: S3.2]: No such file or directory
g++: error: Magic: No such file or directory
g++: error: Square: No such file or directory
g++: fatal error: no input files
compilation terminated.
操作系统:Win7 SP1
VSCode:1.19.3
亚军:0.8.7 5beeedfa674b330537448162dfe9c2330c7eda50
同样的问题。
如下修改配置后:
“ code-runner.executorMap”:{
“ cpp”:“ cd $ dir && g ++ \” $ fileName \“ -o \” $ fileNameWithoutExt \“ && $ dir $ fileNameWithoutExt”}
我可以成功运行前两个命令,但对最后一个命令($ dir $ fileNameWithoutExt)不起作用。
这是输出。
@Michany尝试将$dir$fileNameWithoutExt
更改$fileNameWithoutExt
吗?
@ hanghang0702对不起,我来晚了,你@Michany忘了转义字符,@formulahendry它不是* nix中的系统与./"dir"filename可执行文件运行的问题,
"code-runner.executorMap": {
"javascript": "node",
"java": "cd $dir && javac \"$fileName\" && java \"./$fileNameWithoutExt\"",
"c": "cd $dir && gcc \"$fileName\" -o \"$fileNameWithoutExt\" && \"./$fileNameWithoutExt\"",
"cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt\" && \"./$fileNameWithoutExt\"",
"objective-c": "cd $dir && gcc -framework Cocoa \"$fileName\" -o \"$fileNameWithoutExt\" && \"./$fileNameWithoutExt\"",}
我不是Windows用户,我不确定它是否可以在Windows上运行(您可能需要调整/更改一些转义符或类似内容)。
我真的希望他们在即将发布的版本中对其进行编辑和修复。
同样的问题在这里。
当我在bash终端中运行C代码时。 我得到这个:
bash:cd:d:\ VscodeProjectC \ demo“ && gcc file1.c -o file1 && _d:VscodeProjectCdemo” file1_ :没有这样的文件或目录
显然,不能正确识别最后一个命令。 如何解决?
你好!
我在Mac OS X中有一个相同的问题。此错误有解决方案吗?
如果我将Example 1.cpp重命名为Example1.cpp或Example_1.cpp,那么它可以正常工作...
谢谢!
如果您使用的是Windows,请尝试按以下方式配置设置:
"code-runner.executorMap": {
"cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt.exe\" && & \"$dir$fileNameWithoutExt.exe\""
}
请注意额外的'&'
字符。
如果您使用的是基于Unix的系统,请尝试以下操作(我尚未测试过,但我认为这可以工作):
"code-runner.executorMap": {
"cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt\" && \"$dir$fileNameWithoutExt\""
}
您好,我有同样的问题。 我正在使用Windows,正在尝试运行一个简单的C ++程序,路径或文件名中都没有空格。
[Running] cd "c:\Users\Guillaume\Desktop\" && g++ test.cpp -o test && "c:\Users\Guillaume\Desktop\"test
g++: error: test.cpp: No such file or directory
g++: fatal error: no input files
compilation terminated.
如果我按原样复制命令,然后将其粘贴到cmd.exe中,则它将正常工作:/
我按照其他人的建议进行了更改,但没有任何效果。
编辑:解决了! 这是可能的方法,也许会对其他人有所帮助:
"code-runner.executorMap": {
"cpp": "cd $dir && g++ $dirWithoutTrailingSlash\\$fileName -o $fileNameWithoutExt && $fileNameWithoutExt"
}
你好呀...
我在任何地方都找不到代码运行器,executorMap
我到底在哪里粘贴这段代码...
在settings.json中? ...将代码粘贴到那里是行不通的... :(
你好呀...
我在任何地方都找不到代码运行器,executorMap
我到底在哪里粘贴这段代码...
在settings.json中? ...将代码粘贴到那里是行不通的... :(
是,在settings.json中。
我终于改为使用以下命令:
"cpp": "cd $dir ; g++ $fileName -o $fileNameWithoutExt.exe ; .\\$fileNameWithoutExt.exe"
这是我的settings.json的摘录:
"c-cpp-compile-run.cpp-compiler": "C:\\MinGW\\bin",
"window.zoomLevel": -1,
"code-runner.executorMap": {
//"javascript": "node",
//"php": "C:\\php\\php.exe",
//"python": "python",
//"perl": "perl",
//"ruby": "C:\\Ruby23-x64\\bin\\ruby.exe",
//"go": "go run",
//"html": "\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\"",
//"java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
//"c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"cpp": "cd $dir ; g++ $fileName -o $fileNameWithoutExt.exe ; .\\$fileNameWithoutExt.exe"
},
"C_Cpp.default.cppStandard": "c++20",
"C_Cpp.default.cStandard": "c11",
我相信我也有这个问题。 有解决的计划吗? 这是我的结果:
$ cd "c:\Users\Jacob Armiger\Documents\cpp_files\" && g++ hello.cpp -o hello && "c:\Users\Jacob Armiger\Documents\cpp_files\"hello
bash: cd: too many arguments
您好,尝试了很多时间后,我找到了解决方案,希望这对其他人有帮助
“ cpp”:“ cd $ dir && g ++ \” $ fileName \“ -o \” $ fileNameWithoutExt \“ &&。\\” $ fileNameWithoutExt \“”,
您好,尝试了很多时间后,我找到了解决方案,希望这对其他人有帮助
“ cpp”:“ cd $ dir && g ++” $ fileName“ -o” $ fileNameWithoutExt“ &&。\” $ fileNameWithoutExt“”,
在哪里添加? 在.vscode中的settings.json文件中? 或者别的地方?
->是的,您需要将其复制到vscode的settings.json(完全在执行者映射中)上,我将附上一张照片
Windows伙计们!
只需将“过去”复制到您的settings.json文件中
我做了很多研究,这肯定会起作用
"code-runner.executorMap": {
"cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt\" && \"$fileNameWithoutExt\""
},
如果您使用的是Windows,请尝试按以下方式配置设置:
"code-runner.executorMap": { "cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt.exe\" && & \"$dir$fileNameWithoutExt.exe\"" }
请注意额外的
'&'
字符。如果您使用的是基于Unix的系统,请尝试以下操作(我尚未测试过,但我认为这可以工作):
"code-runner.executorMap": { "cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt\" && \"$dir$fileNameWithoutExt\"" }
这对我有用。 我现在可以编译并运行c cpp和java文件(即使有人在想,java中也不需要'&')
如果您使用的是Windows,请尝试按以下方式配置设置:
"code-runner.executorMap": { "cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt.exe\" && & \"$dir$fileNameWithoutExt.exe\"" }
请注意额外的
'&'
字符。如果您使用的是基于Unix的系统,请尝试以下操作(我尚未测试过,但我认为这可以工作):
"code-runner.executorMap": { "cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt\" && \"$dir$fileNameWithoutExt\"" }
这个解决方案有效!! 最后,我的c程序可以编译并运行。 谢谢!
真的有帮助,谢谢!
我在Windows上
请帮助!!!😭我遇到了同样的错误。
{
"atomKeymap.promptV3Features": true,
"editor.multiCursorModifier": "ctrlCmd",
"editor.formatOnPaste": true,
"python.pythonPath": "C:\\Users\\ABHISHEK\\anaconda3\\python.exe",
"java.home": "C:\\Program Files\\Java\\jdk-12.0.2",
"java.help.firstView": "gettingStarted",
"workbench.iconTheme": "vscode-icons",
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"java.semanticHighlighting.enabled": true,
"files.exclude": {
"**/.classpath": true,
"**/.project": true,
"**/.settings": true,
"**/.factorypath": true
},
"python.jediEnabled": false,
"python.dataScience.sendSelectionToInteractiveWindow": true,
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"python.languageServer": "Microsoft",
"files.associations": {
"*.cpp": "cpp"
},
"C_Cpp.updateChannel": "Insiders",
"code-runner.executorMap": {
"javascript": "node",
"java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
"c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
"cpp": "cd $dir && g++ \"$fileName\" -o \"$fileNameWithoutExt.exe\" && & \"$dir$fileNameWithoutExt.exe\"",
"objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir $fileNameWithoutExt",
"php": "php",
"python": "python -u",
"perl": "perl",
"perl6": "perl6",
"ruby": "ruby",
"go": "go run",
"lua": "lua",
"groovy": "groovy",
"powershell": "powershell -ExecutionPolicy ByPass -File",
"bat": "cmd /c",
"shellscript": "bash",
"fsharp": "fsi",
"csharp": "scriptcs",
"vbscript": "cscript //Nologo",
"typescript": "ts-node",
"coffeescript": "coffee",
"scala": "scala",
"swift": "swift",
"julia": "julia",
"crystal": "crystal",
"ocaml": "ocaml",
"r": "Rscript",
"applescript": "osascript",
"clojure": "lein exec",
"haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
"rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
"racket": "racket",
"scheme": "csi -script",
"ahk": "autohotkey",
"autoit": "autoit3",
"dart": "dart",
"pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
"d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
"haskell": "runhaskell",
"nim": "nim compile --verbosity:0 --hints:off --run",
"lisp": "sbcl --script",
"kit": "kitc --run",
"v": "v run",
"sass": "sass --style expanded",
"scss": "scss --style expanded",
"less": "cd $dir && lessc $fileName $fileNameWithoutExt.css"
},
"window.zoomLevel": 0,
"files.autoSave": "onFocusChange",
"diffEditor.ignoreTrimWhitespace": false,
"[cpp]": {
"editor.wordBasedSuggestions": false,
"editor.suggest.insertMode": "replace",
"editor.semanticHighlighting.enabled": true
},
"code-runner.runInTerminal": true,
"code-runner.saveAllFilesBeforeRun": true,
"settingsSync.ignoredSettings": [
"-java.configuration.runtimes"
],
"liveServer.settings.donotShowInfoMsg": true,
"java.refactor.renameFromFileExplorer": "autoApply",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"eslint.codeAction.showDocumentation": {
"enable": true
},
"git.autofetch": true,
"vsicons.dontShowNewVersionMessage": true,
}
这和我仍然遇到相同的错误。
而我的环境变量:
并且以防万一有人怀疑我的文件之类的东西...
@formulahendry @HeyJayant @ kaushik-rishi
@ VipulKhandelwal1999谢谢你的工作!
@ushakhanal阅读了我的评论。 我已经解释了“参数过多”错误时的处理方法。
最有用的评论
如果您使用的是Windows,请尝试按以下方式配置设置:
请注意额外的
'&'
字符。如果您使用的是基于Unix的系统,请尝试以下操作(我尚未测试过,但我认为这可以工作):