0. Introduction (You can skip this section if you already know the background)
The Windows build 14316 version has been added to the "Linux Subsystem for Windows systems" (Windows Subsystem for Linux, hereinafter referred to as WSL) feature, which is a complete Linux system. Sublime text is a fast and powerful code editor. Now most of the online tutorials on sublime text configuration gcc/g++ compiled environments are tools such as MinGW, which tell you how to use WSL to create an authentic gcc/g++ compilation environment.
1. Installing WSL
(Refer to document HTTPS://DOCS.MICROSOFT.COM/EN-US/WINDOWS/WSL/INSTALL-WIN10)
Enter in the Power Shell for administrator privileges
Enable-windowsoptionalfeature-online-featurename Microsoft-windows-subsystem-linux
If necessary, restart your computer.
If your version of Windows is larger than build 16215, please continue to install the release version for WSL in Windows store, I chose Ubuntu. Basic configuration after the installation is complete.
Finally, verify that the installation is successful, enter "bash" under PowerShell or CMD, and if you enter the subsystem, the installation is successful.
2. Installing the gcc/g++ Compilation tool for WSL
Execute in Bash
sudo sudo Install build-essential
The installation is started after confirmation.
3. Install sublime Text 3 and configure the gcc/g++ compilation environment
Download and install from sublime text website: https://www.sublimetext.com/
When you are finished, open the sublime software, open: Tools->build system->new Build System, for GCC, for example, enter the following:
{ "cmd": ["Bash", "-C", "GCC ${file_name}-o ${file_base_name} &&./${file_base_name}"], true, "Working_dir": "${file_path}",}
Save As Wslgcc.sublime-build, the file is under Sublime Packages/user folder.
4. Test whether the configuration is successful
Select the WSLGCC compilation environment that you just configured in Tools->build System and create a file to test:
#include <stdio.h>int main () { printf ("hello world!\n") ; return 0 ;}
Press Ctrl+b to compile the run, you can see the results of the operation:
P.S. If there are omissions or improvements, please leave a comment in the comments section.
gcc/g++ compilation environment under Windows Sublime Text configuration Linux subsystem (WSL)