65,159
社区成员




C++新人,买了本书,照着视频教程安装了vscode和c++环境,用code runner运行时,有的文件没问题,有的却无法生成.exe文件。
code runner的命令设置修改一下。你的配置中g++的参数-o的文件名没有.exe的后缀名,导致不能正确运行.。后面的if中有rm的那个可以删除了。rm是linux命令,win下没有。
setting.json里的"code-runner.executorMap"中修改cpp那一段
可以直接修改成
"cpp": "cd $dir &&g++ $fileName -o $fileNameWithoutExt.exe && $fileNameWithoutExt.exe",
补充一点:不用code runner就能运行。