Sublime Forum

Setting Sublime up for C++

#1

I’m curious how I would go about setting up Sublime to compile c++ projects.

I’ve got mingw as a compiler. Do I have to create a .make file somewhere? Do I change something in the .sublime-project?

Thanks for any suggestions.

–beagle

0 Likes

#2

Well I figured it out myself. I’ve freed myself from the shackles of Visual Studio! Yay!

0 Likes

#3

Good to hear… if you’re working with C/C++, you’ll find Alt+O handy to toggle between .h/.cpp files.

0 Likes

#4

I however would like to know how to do this. I’ve been fooling around with it for a while, and can’t seem to figure it out. I’ve also done a fair amount of googling and searching of the site and the blog. Any insight that can be provided would be appreciated.

0 Likes

#5

I’m writing up some documentation for the Build Systems, which should be up some time over the next few days.

Is your project Makefile based, or is it an existing Visual Studio .sln one?

0 Likes

#6

The way I got it to work was:

You need the following:

  • A c++ compiler – I downloaded mingw, I’m sure there are others.
  • A make program – mingw comes with one.

Sublime tries to call ‘make’ from the command line when you build your project. The make program mingw comes with is called mingw32-make.exe, so I renamed it to make.exe so that sublime can recognize it.

You also have to add mingw’s \bin folder to the windows PATH so that it’s visible to sublime.

So now that you’re all set up to run make and compile the program, you have to make the makefile. The makefile should be called ‘makefile’ with no file extension (you might be able to call it something else, but I’m not sure what. Go google it)

If you know how to make makefiles, great. I had been using Visual Studio for years though, and I was incredibly ignorant of how they work. I just knew that they were important for compiling linux stuff from source. Anyways, I googled for makefile tutorial and used this site:
http://www.opussoftware.com/tutorial/TutMakefile.htm

So once you figure that out, just put the makefile in your Sublime project directory and then hit build. If you made the makefile correctly it should work.

I know it’s not the best how-to, but maybe it’ll help. It might be easier to just compile your stuff from the command line directly and skip the makefile.

If there’s an easier way to do this please tell me haha.

0 Likes

#7

I know this is an old topic but I am having trouble setting this up for the past hour. I am currently having to copy the code from Sublime and pasting it into Visual Studio just to compile it and it’s getting really annoying. I tried to follow beagles post but just don’t understand how to do this. Is there anyway someone can post a video or maybe do a complete step by step so that I can get this setup? At first I thought purchasing the full version would add the C++ Build System under the tools menu but that was wrong. Thanks.

0 Likes