Sublime Forum

Making sublime text compile C/C++ code

#1

can someone please write the steps for configuring this editor to compile cpp files?
dont quite understand the make cmd procedure. your help will be appreciated.

0 Likes

#2

These instructions assume some level of prior knowledge:

  1. How to write and test a make file
  2. How to write and test a regular expression

Steps

  1. You need to have a working make file that works correctly from a terminal
  2. Next launch ST2 from the command line; if you launch it from a GUI you won’t pick up your environment variables
  3. Create a file, name it “myproject.sublime-project”; put the following in it, and save.

{
“build_systems”:

    {
        "name": "my build",
        "cmd": "make"],
        "file_regex": "^ ]*File \"(...*?)\", line ([0-9]*)",
    }
]

}

  1. Open the project: Project/Open Project…

  2. Select your build rule: Tools/Build System/myproject

  3. Select build: Tools/Build

  4. Build results will appear in a new window on the bottom.

  5. F4 should take you to your first error. If not, then you need to fix the regular expression in the project file so that the first grouping selects the file name, and the second selects the line number.

0 Likes

#3

i’m sry. i’m fairly new to this - that is why i posted this question. the only compiler i ever used is visual studio for school :confused:

i’m really interested in dumping vs2010 for ST2. can you be more specific? (the noob’s guide to cpp with ST2)

0 Likes

#4

I would be interested in this guide too.

0 Likes

#5

As cool as sublime is, it isn’t an ide. It is really for people who are comfortable using a command line for development. I suggest that you spend some time learning about:

  • shell use and scripting
  • regular expressions
  • makefiles

You can use sublime as your editor, but you will need command line development skills to go with it.

0 Likes

#6

knowledge is always helpful in every aspect of life :smile:

i thought there is a way to just link a compiler to sublime so i could code->build->debug.
are you telling me that is impossible without mastering shell use and scripting\ regular expressions\ makefiles?

0 Likes

#7

Maybe this can help you: http://joshgoodman.co.za/makefile-notes

0 Likes

#8

Any other SIMPLE Guides to make a makefile to compile a c++ program?

I’m only persisting because I love sublime’s GUI, and I don’t want to go back to something like Dev-C++…
SIMPLE Guides anyone?

0 Likes

#9

where to download “myproject.sublime-project”? in which directory?

ST is not able to read and keep loading its default build.
Tools>Build System>New System
How to overwrite default New System in Sublime
What is the command to run in
{
“shell_cmd”: “make”
}

0 Likes

#10

[quote=“bluepimple”]where to download “myproject.sublime-project”? in which directory?

ST is not able to read and keep loading its default build.
Tools>Build System>New System
How to overwrite default New System in Sublime
What is the command to run in
{
“shell_cmd”: “make”
}[/quote]

bluepimple watch this video: https://tutsplus.com/lesson/custom-builds/ It should provide more information for you. Come back here, if you have more questions.

Also take a look at this: http://docs.sublimetext.info/en/latest/reference/build_systems.html

0 Likes