C++11 and Sublime Text 2

Wanting to test out C++11, I first tried using Visual Studio 2012 hoping they would have implemented most of the standard. I first started with the literal operator, and apparently it’s not implemented yet, bummer.

Since I love Sublime Text 2 and I hadn’t tried the build system on it yet, I decided to try it out with gcc.

Unfortunately (on Windows), when using Tools -> Run, you will be greeted with:

[Error 2] The system cannot find the file specified
[cmd:  [u'bash', u'-c', u"g++ 'C:\\Development\\C++11\\helloworld.cpp' -o 'C:\\Development\\C++11/helloworld' && 'C:\\Development\\C++11/helloworld'"]]
[dir:  C:\Development\C++11]
[path: ... my path ... ]
[Finished]

This is simply because the platform doesn’t provide bash and g++. It can easily be fixed though.

This MinGW distro provides you with everything you need to compile (gcc 4.7.2) and this port of bash does a pretty good job. You simply need to add the path where you put these files to the Environment Variable PATH.

After restarting Sublime Text 2 so it gets the new environment variables, you should be able to compile and run your file, giving you an output similar to:

Hello World.
[Finished in 2.7s]

Leave a Reply

Your email address will not be published. Required fields are marked *