从Sublime Text使用Windows子系统Linux(WSL)

Fon*_*lis 6 linux windows bash sublimetext windows-subsystem-for-linux

我想使用gcc,g++make从Sublime能够编译c和c ++代码到Winows上的Linux runnables.我无法bash.exe从Sublime 运行,就像stackoverflow上的许多其他用户一样.

Fon*_*lis 6

  1. 您必须将C:\Windows\System32\bash.exe文件复制到该C:\Windows\SysWOW64\目录.因为WoW64文件系统重定向而需要(感谢Martin!)

  2. 然后,您必须使用以下代码在Sublime Text中创建新的构建系统.(Tools -> Build System -> New Build System...)

    {
      "cmd" : ["bash", "-c", "gcc ${file_name} -o ${file_base_name} && ./${file_base_name}"],
      "shell": true,
      "working_dir": "${file_path}",
    }
    Run Code Online (Sandbox Code Playgroud)

    此代码将编译.c代码而不是运行它.输出将显示在Sublime的Build Results面板中.

  3. 如果要使用此Build System,请在Tools -> Build System列表中选择它,然后单击Ctrl + B.

您可以自定义我放在那里的命令,主要是您可以使用运行Linux命令 bash -c "CommandsYouWantToRun"

  • 另请注意:由于[WoW64文件系统重定向](https://msdn.microsoft.com/es-es/library/windows/desktop/aa384187(v = vs.85).aspx),因此需要执行步骤#1 (3认同)