Why can't I build C ++ in Sublime Text 2?
I am using Windows 7 x64 and I am trying to generate C ++ code in Sublime Text 2.
//C++ Code Here
#include <iostream>
void main()
{
cout << "HelloWorld " << endl;
}
Then after building (or running) I get an error like below.
[Error 2]
[cmd: [u'g++', u'C:\\Users\\Johnny\\AppData\\Roaming\\Sublime Text 2\\Packages\\C++\\C++.sublime-build', u'-o', u'C:\\Users\\Johnny\\AppData\\Roaming\\Sublime Text 2\\Packages\\C++/C++']]
[dir: C:\Users\Johnny\AppData\Roaming\Sublime Text 2\Packages\C++]
[path: C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Wizvera\Delfino;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;;C:\Program Files\Broadcom\Broadcom 802.11 Network Adapter\Driver;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\APM_Setup\Server\Apache\bin;C:\APM_Setup\Server\MySQL5\bin;C:\APM_Setup\Server\PHP5;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ESTsoft\ALSee\x64]
[Finished]
I found Sublime Text 2 C ++ build script (C ++. Sublime-build) which was thought to be correct for use by some:
{
"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{
"name": "Run",
"cmd": ["${file_path}/${file_base_name}.exe"]
}
]
}
But I am still getting the same error. I can't seem to find a solution that allows it to run C ++ code in Sublime Text 2. What's wrong with my C ++ build configuration?
+3
source to share
1 answer
You are missing a real compiler environment like MinGW. Sublime Text is only an editor, not a full fledged IDE, you will need additional software like MinGW or similar.
Note. This answer is based on the comment of the original author.
+2
source to share