gcc/g++ compilation environment under Windows Sublime Text configuration Linux subsystem (WSL)

Source: Internet
Author: User
Tags sublime text

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.