Use SublimeText2 to build the VC compiling environment

Source: Internet
Author: User
I used to use the bloated VS2013. Sometimes I want to write a small project, a small test program, and edit the code. I don't want to open it all, as a result, I threw myself into SublimeText2, a powerful modern code editor, which is positioned to be light green and fast. It also supports WinMacLinux and 32-bit and 64-bit cross-platform support, however, it needs to work with many

I used to use the bloated VS2013. Sometimes I want to write a small project, a small test program, and edit the code. I don't want to open it all, as a result, I made a fuss about Sublime Text2, a powerful modern code editor, which is positioned to be light green and fast, and supports Win, Mac, and Linux across platforms, supports 32-bit and 64-bit, but it must work with a large number


I used to use the bloated VS2013. Sometimes I want to write a small project, test a program, and edit the code.

I opened it, so I threw myself into Sublime Text2, a powerful modern code editor, and its positioning

It is light green, fast, and supports windows, Mac, and Linux on a cross-platform basis. It supports 32-bit and 64-bit, but it needs to work with a large number

Plug-ins are used together, so it is more suitable for people who like tossing.

In addition, Sublime Text2 is usually used for front-end development, such as HTML, PHP, or scripts,

Like Lua, Js, and so on, but it is estimated that there are not many other convenient tools to use it to write VC. After all, there are convenience artifacts such as VS, so I am here

We will share with you how to use it to build a VC compiling environment.


Prerequisites:

(1). Download Sublime Text2

The download of Sublime Text2 is not detailed. You can download the English version from the official website and use the registration machine to crack it. If you want

If you want to save some trouble, you can download the Chinese cracked version from the Internet.


(2) about Package Control

This is a plug-in that facilitates the management of other plug-ins, but in tianchao you must use VPN or use proxy to flip the wall, otherwise you will obtain

No updates are useless, but they are not necessary. You can download the plug-in from github or other download sources and manage it manually.

Place the plug-in package in the Sublime Text2/package directory.


(3) usage of Cl compiler for MS

Here I am not planning to use the GCC/G ++ of MINGW. Because it is a VC project, it is more appropriate to build the Cl compiler under VC,

I am also used to using this compiler. (Why can I steal it from VS2013 ?)


Official construction:

(1). Set the environment variable (if not, create a new one)

Take the local machine as an example:

1. Add in INCLUDE of System Variables

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 it to 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 VC_BIN in system variables 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 reminder: it may not take effect immediately after adding it. At this time, you need to restart the machine. Enter the set command in cmd to check whether the setting is successful.


(2). New Build generates the New compilation system file

1. Click, add the following code to the file, and save it 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. Save and set the compilation system to VC ++,


(3) import the default inherited lib library in VC

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



(4) download the ConvertToUTF8 plug-in

Because Sublime Text2 does not support Chinese very well, we need this plug-in to manage Chinese Character garbled characters

For other issues, press Ctrl + Shift + P and enter Package Control to manage the installation of the plug-in.

(You can also directly download the Package to the SublimeText2/Package directory)


Here, I compile and run a WIN32 program to illustrate the role of this plug-in. Here I have prepared a transfer

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

Ctrl + Shift + B, then it starts to compile and run, and then we can see a compilation error:


Here, the "constant has a line break" error is caused by Chinese characters, the solution is to save it as a UTF-8 containing BOM format, and then

Ctrl + Shift + B:


Running result:


(5). SublimeClang plug-in and API code prompts

Because Sublime Text2 only supports code prompts of existing variables, if you do not want to blindly refer to MSDN,

You can use the SublimeClang plug-in to provide code prompts for C ++ APIs.

Can be obtained using Package Control, I provide another one here: http://pan.baidu.com/s/1hq7iXHM

In addition, I have mentioned the use of SublimeClang. After this plug-in is included in the Package,

Click Preferences> Package Settings> SublimeClang> Settings User to save the code.

Here I turn off the error check and it feels a bit problematic:

{"Show_output_panel": false, // the following code prompt box shows "show_visual_error_marks": false, // The Wrong red box shows "dont_prepend_clang_includes": true, // whether the clang header file is excluded. We recommend that you use true to cancel the inclusion to prevent "options": [// "-IF: \ Graphic_proj"]} conflict.

The header file path identified by SublimeClang added in "options", so that it can be identified to use the code prompt function,

Because we have previously set environment variables, we do not need to add them here. For specific usage instructions, refer

Preferences-> Package Settings-> SublimeClang-> Settings Default,

After the setting is successful, we can use the following code prompt function:

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.