Sublime Forum

C/C++ Installation

#1

How can I easily build and run C/C++ program on Sublime Text 3 on windows 10?

0 Likes

#2

Sublime ships with a build system for C and C++ called C Single File (or C++) that can compile a single file program, or compile it and then run it for you. So the easiest way to get going would be to make sure that you have gcc/g++ installed, set the Tools > Build System menu item to Automatic, and then use Tools > Build to trigger a build, which will ask you if you want to just compile, or compile and run.

If you want to use a different compiler toolchain (like the VS compiler), compile and run a program with more than one file, change the parameters passed to the compiler, add new libraries to the linker or (most importantly) run a program of any sort that you need to interact with, then you’re going to need to do more work.

Sublime is language agnostic, so unlike an IDE it doesn’t contain built in rules simplify the building and running complex applications like an IDE would. Instead it just executes some external tool and allows that tool to do the job.

Hence, for anything more fancy than a simple single (non-interactive) file, you need to create your own sublime-build file that tells Sublime how to do it, and that requires that you know how to do it yourself so that you can instruct Sublime on what to do. It also requires you to install the tools that you want to execute as well.

I have a video series on Build systems in Sublime Text that covers how sublime-build files work, how to create one, how to use one to run an interactive program, etc that may be of help in getting set up.

1 Like