Sublime integrated MinGW to create a/C + + development environment

Source: Internet
Author: User
Tags sublime text

MinGW is the product of porting the GCC compiler and the GNU Binutils to the Win32 platform, including a series of header files (WIN32API), libraries, and executables. MinGW was developed from the Cygwin (1.3.3 version). Most of the languages supported by GCC are also supported in MinGW, which covers C, C + +, OBJECTIVE-C, Fortran, and Ada. For languages other than C, MinGW uses the standard GNU runtime, such as C + + using the GNU libstdc++. However, MinGW uses the C Runtime library in Windows. Therefore, programs developed with MinGW do not require additional third-party DLL support to run directly under Windows, and do not necessarily have to comply with GPL licenses. This also caused the program developed by MinGW to use only Win32API and cross-platform third-party libraries, and without POSIX support [3], most GNU software cannot compile with MinGW without modifying the source code. Specific details can be seen on the official website.

First, download MinGW

After the download is complete, double-click Open to start the installation, it is recommended to install to the C drive

When the installation is complete, the desktop will appear with one of the following icons:

This is an installer, double-click to open the following interface:

Right-click on "Mark for Installation" and select "Installation, Apply changes". Wait for the download to complete.

Second, the configuration MINGW environment variable

After the installation is complete, configure the environment variables, the g++ compiler in the bin directory, configured as follows:

Third, configuration sublime Text 3

Click Tools--Build system--and new Build system, which opens a new page, copies the following content, and saves it as Myc++.sublime-build

{"cmd": ["g++", "${file}", "-O", "${file_path}/${file_base_name}"], "File_regex": "^ (.. [^:]*]:([0-9]+):? ([0-9]+)?:? (. *) $ "," Working_dir ":" ${file_path} "," selector ":" Source.c, source.c++ "," Encoding ":" cp936 "," Variants ": [    {        "Name": "Run", "        cmd": ["${file_path}\\\\${file_base_name}.exe"]    }]}

You only need to Ctrl+B see the output in the sublime Text 3 console after you call compile and then type Ctrl+Shift+B run.

Iv. Testing

Create a new test.c file, Ctrl+b,ctrl+shift+b, and run the following results:

#include <stdio.h>int main () {printf ("Hello world!\r"); printf ("Xixi"); printf ("Hello world!\n"); printf ("Xixi") ; printf ("Hello world!\r\n"); printf ("Xixi"); return 0;}

  

Sublime integrated MinGW to create a/C + + development environment

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.