我想使用Sublime的gcc、g++和make,以便能够将c和c++代码编译成Linux在Winows上可运行的代码。我不能从Sublime运行bash.exe,就像许多其他用户在stackoverflow上一样。
发布于 2016-11-07 13:02:04
C:\Windows\System32\bash.exe文件复制到C:\Windows\SysWOW64\目录。由于WoW64 file system redirection而需要(感谢Martin!)Tools -> Build System -> New Build System...){ "cmd“:"bash","-c","gcc ${file_name}外壳${file_base_name} && ./${file_base_name}","shell":true,"working_dir":"${file_path}",}
这段代码将编译.c代码,然后运行它。输出将显示在Sublime的构建结果面板中。
Tools -> Build System列表中将其选中,然后单击Ctrl + B.您可以定制我放在那里的命令,主要是您可以使用bash -c "CommandsYouWantToRun"运行Linux命令。
发布于 2020-10-09 03:45:02
在WSL2中,根据我的说法,最好的方法是使用下面的sublime-build文件。
(Tools -> Build System -> New Build System...)
{
"shell_cmd": "ubuntu run \"g++ `wslpath '${file}'` && ./a.out<inp.in>out.in \" ",
"shell":true,
"working_dir":"$file_path",
"selector":"$file_name"
}Optional, if you don't want that, then replace ./a.out<inp.in>out.in with ./a.out)。输出将显示在Sublime的构建结果面板中。如果要使用此构建系统,请在Ctrl + B.列表中将其选中,然后单击
发布于 2020-07-08 19:04:51
在WSL 2上,建议的解决方案不起作用。这是一个在WSL2目标上执行Windows上用Sublime Text编辑的脚本的解决方案。创建bash-wsl.sublime-build文件:
{
"shell_cmd": "bash -c \"wslpath '${file}'\" | bash -s",
"shell": true,
}https://stackoverflow.com/questions/40455673
复制相似问题