How to compile code using Sublime?

Asked

Viewed 2,601 times

-1

I wonder if I can add a compiler to the sublime to compile things straight from the program, more practical like this.

1 answer

1

How do you compile your programs? Do you have an environment variable referencing a binary to run on command line? Because in the sublime works more or less like this, I do not know for sure in the previous versions but in the current version the Sublime Text 3 has an area called builds, from which you can run commands building of its application.

I’m not a C++ developer but I use Sublime builds daily working with Node.js, so I think it’s the same process. For now, I’ll explain how building works using Node.js simply by not having a C++ environment installed. When you can answer me those questions from the beginning, I can then update this answer with the appropriate information.

Step by step

  • Go to Sublime > Tools > Build System > New Build System

Done this I believe Sublime opened a new file with the extension .sublime-build which must be saved within ./Packages/User/. Follow the file settings:

{
  "shell_cmd": "node $file"
}

Realize where you are node should be the environment variable of your machine referencing the torque responsible for compiling its scripts C++ and the parameter $file is a reference to the current program that will be compiled.

  • After you have saved the file on ./Packages/User/. Go to Sublime > Tools > Build System > filename

When you want to compile your programs, press Ctrl + B.

IMPORTANT: The Sublime does not "kill" the process, even if you press Ctrl + C or Esc the building will continue running on background. If you want to end the process, go to Sublime > Tools > Cancel Build (a.k.a Ctrl + Break).


One more Thing...

I am currently using Windows then the terminology I used was based on my OS. If you are using another system I believe you will have to do a search for "interwebs" regarding how to configure them.

  • If the answer was helpful to you, I’d be happy if you could mark it as the right one.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.