Using sublime Text2 to build VC compiling environment

Source: Internet
Author: User


Used to the bloated VS2013, sometimes want to write a small project, a small test program, edit browsing code or not

Always open it, so I toss a bit sublime Text2 this modern tall on the powerful Code editor, it's positioning

Is green, lightweight, fast, and supports win/mac/linux across platforms, supporting 32 and 64-bit, but it needs to match many

Plug-in together, so it is more suitable for those who like to toss.

In addition, Sublime Text2 is usually used for front-end development, such as html,php, or to write scripts for God horse,

Like Lua, JS and so on, but estimated to use it to write VC is really not much, after all, there is a vs such convenience artifact, so I am here

Share how to use it to build a VC build environment.


Premise:

(i). About Sublime Text2 download

About Sublime Text2 Download is not detailed said, you can go to the official download English version, and then use the registration machine to crack, if you want to

The use of Chinese, can be Chinese, if you want to save a little bit, you can also directly to download Chinese cracked version of the Internet.


(b). About the package Control

This is a convenient plug-in to manage other plug-ins, but in the celestial kingdom you must be able to use a VPN or proxy over the wall, otherwise you get

Not the update is useless, but it is not necessary, you can go to github or other download source download plugin, manually manage

Place the plug-in package under the sublime Text2/package directory.


(iii). Use of the CL compiler for MS

Here I do not intend to use MinGW gcc/g++, because it is a VC project, it should be built under the VC of the CL compiler more appropriate,

And I'm used to using this compiler. What if it's stolen from the VS2013? )


Formal Construction:

(i). Set environment variables (if not, create new)

Here is the example of this machine:

1. Add in the include of the system variable

E:\Ultimate_VS2013\VC\include;

C:\Program Files (x86) \ Windows kits\8.1\include\shared;

C:\Program Files (x86) \ Windows Kits\8.1\include\um;

C:\Program Files (x86) \ Windows KITS\8.1\INCLUDE\WINRT;


2. Add in the lib of the system variable

E:\Ultimate_VS2013\VC\lib;

E:\Ultimate_VS2013\VC\atlmfc\lib;

C:\Program Files (x86) \ Windows Kits\8.1\lib\winv6.3\um\x86;

C:\Program Files (x86) \ Windows Kits\8.1\lib\winv6.3\um\arm;


3. Create a new vc_bin in the system variable and add

E:\Ultimate_VS2013\VC\bin;

C:\Program Files (x86) \ Windows Kits\8.1\bin\x86;

C:\Program Files (x86) \microsoft Sdks\windows\v8.1a\bin\netfx 4.5.1 Tools;

E:\Ultimate_VS2013\Common7\IDE;

and add it to the path variable of the system variable, such as%vc_bin%


Friendly tip : Just add may not immediately take effect, this time need to restart the machine, in CMD enter the SET command to see if the settings are successful.


(b). New build builds a newly compiled system file

1. Click "Tools-" compile system-"new compiled system", add the following code to the file and save as Vc++.sublime-build

{    "cmd": ["CL", "/fo${file_base_name}", "/o2", "${file}"],    //For CL on Windows       "File_regex": "^ (.. [^:]*]:([0-9]+):? ([0-9]+)?:? (. *) $ ",      " Working_dir ":" ${file_path} ",      " selector ":" Source.c, source.c++ ",       //" encoding ":" Utf-8 ",    "Encoding": "cp936",      "variants":      [          {              "name": "Run",                        "cmd": ["cmd", "/U", "/C", "Cl/fo${file _base_name}/o2 ${file} && ${file_base_name} "]   //For CL on Windows           }      ]   }

2. Set the compilation system to VC + + after saving,


(iii). Import the default inherited Lib Library from VC

We can write a header file and manually import these Lib libraries, for example:



(d). Download the ConvertToUTF8 plugin

Because sublime Text2 support for Chinese is not very good, so we need this plugin to manage characters garbled

And so on, we can press Ctrl+shift+p to enter the package control to manage the installation of the plugin.

(can also be downloaded directly in the Sublimetext2/package directory)


Here, I use a WIN32 program compiled to run to illustrate the role of the plug-in, where I wrote a pre-delivery

A bitmap display of the GDI program, save it in the main.cpp. We first click on the main.cpp file and then press

Ctrl+shift+b, and then it starts compiling and running, and then we can see that a compilation error has occurred:


Here, the "line break in Constants" error is exactly what the Chinese characters bring, and the solution is to save the UTF-8 with the BOM format, and then

Ctrl+shift+b compile and run there will be no problem:


Operation Result:


(v). About the Sublimeclang plugin and API code hints feature

Because the sublime Text2 itself only supports code hints for existing variables, if you do not want to blindly refer to MSDN,

You can use the Sublimeclang plugin to provide code hinting about the C + + API, Sublimeclang

Can be obtained by using the package control, I offer another one here: Http://pan.baidu.com/s/1hq7iXHM

In addition, with regard to the use of Sublimeclang, I would mention it in passing, after including the plugin in the package,

We can save the code by clicking Preferences->package settings->sublimeclang->settings User

To make your own settings, I've turned off the bug check here and I feel a bit of a problem:

{    "Show_output_panel": false,             //The Code hint box below shows    "Show_visual_error_marks": false,//Error red box    "Dont_ Prepend_clang_includes ": True,    //does not include Clang's own header file. It is recommended to cancel including in case of conflict       "options":    [        //"-if:\\graphic_proj"    ]}

The Sublimeclang recognized header file path that is added in the "options" so that it can be identified to use the code hinting function,

Because we have set the environment variable before, so there is no need to add, the specific use can refer to

Preferences->package settings->sublimeclang->settings Default,

After the setup is successful, we can use the following code hinting function:



Using sublime Text2 to build VC compiling 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.