[Development tool]_[sublime Text 2]_[config C + + compilation Run Environment]

Source: Internet
Author: User
Tags sublime text


1. g++ version update is faster, you can use the latest c++11 features, here Sublime Text 2 is my lightweight C + + development tool (only this), you can use ST2 this tool to verify some of the new syntax features.

2. The benefits of ST2 are free, as well as support for multi-lingual syntax highlighting and function outline

3. Of course ST2 also supports plug-in development.

4. Add the selected file to the sublime text 2 right-click to open the look here:



Configuring C + + Compilation options

1. First look at the menu tools-> build system-> C + + has this compiler system, but this compilation system must be g++ configured to the environment variable, even if the compilation run is also problematic.

This error will appear [ERROR 2]. Here, we're just looking at this thing. You can copy the C + + compilation system for modification.

2. Menu Preferences-> Browse Packages ...

Go to the C + + directory, then open C++.sublime-build, and select Copy all of the contents.

3. Menu Tools-> build system->new build System ...

Will come out a new file, paste just the C + + configuration item, modified to (here the configuration items are basically JSON format, so note the comma), in fact, the first line configuration and the last line of configuration items are changed.

{"cmd": ["c:/software/tdm-gcc-64/bin/g++", "${file}", "-O", "${file_path}/${file_base_name}"], "File_regex": "^ (.. [^:]*]:([0-9]+):? ([0-9]+)?:? (. *) $ "," Working_dir ":" ${file_path} "," selector ":" Source.c, source.c++ "," variants ": [{" Name ":" Run "," cmd ": [" ${file_ Path}/${file_base_name} "}]}

4. Save the file as sai-c++ (note that the name here is the name of the build system, set the appropriate name yourself), the filename suffix or sublime-build.

So in tools-> build system-> There is a sai-c++ build system, select the building system we just built. I set the absolute path of g++ here because I didn't add it to the environment variable,

If there is a variable added to the environment, direct g++ can be done.

5. This allows you to create a new test.cpp to run the compilation.

6. Another problem is that the shortcut keys are not working, ctrl+shift+b, so we also need to define their own shortcut keys.

7. Menu Preferences-> key Bindings-default, here Open the default configuration item, we do not modify it, just copy the configuration of the Ctrl+shift+b run

{"Keys": ["Ctrl+shift+b"], "command": "Build", "args": {"Variant": "Run"}},

Then open

Menu preferences-> key Bindings-user, I changed it here. Shortcut keys for deleting rows.

[{"Keys": ["Ctrl+d"], "command": "Run_macro_file", "args": {"file": "Packages/default/delete Line.sublime-macro"}},{" Keys ": [" Ctrl+r "]," command ":" Build "," args ": {" Variant ":" Run "}}]

8. Then open our test.cpp, ctrl+b compile, ctrl+r run.

#include <iostream>using namespace Std;int main (int argc, char const *argv[]) {cout << "Hello World" << E Ndl;return 0;}


[Finished in 0.8s]

Hello world[finished in 0.1s]

9. Debug the word using GDB directly at the command line debugging bar, Sublimet text 2 of a GDB debugging plugin is not stable.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

[Development tool]_[sublime Text 2]_[config C + + compilation Run Environment]

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.