I installed gcc (only gcc) from the MinGW website on my Windows 8.1 machine and it is working perfectly if used from the command prompt or from the PowerShell. But I am having trouble compiling and running C programs with Sublime Text 2. If I only compile it (Tools -> Build) it works perfectly and I get my executable file as wanted. The .exe works (i.e. if I run it manually it works perfectly). The problem is that Sublime Text does not work if I do Tools -> Run. I receive this error message in Sublime:
[Error 2] The system cannot find the file specified
[cmd: [u'bash', u'-c', u"gcc 'E:\\Desktop\\Test\\HelloWorld.c' -ansi -pedantic -Wall -o 'E:\\Desktop\\Test/HelloWorld' && 'E:\\Desktop\\Test/HelloWorld'"]]
[dir: E:\Desktop\Test]
[path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Skype\Phone\;C:\MinGW\bin]
[Finished]
A professor provided us the following code that I used to create a Sublime Build file (he uses a Mac, can this be the problem?):
{
"cmd": ["gcc", "-ansi", "-pedantic", "-Wall", "${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": ["bash", "-c", "gcc '${file}' -ansi -pedantic -Wall -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
}
]
}
I tried looking for previously asked questions and found a couple, but none of them included the gcc switches I want to use: -ansi -pedantic -Wall. In addition the answer provided in the questions opened a new command prompt window to execute the .exe file, while I wanted to see the execution in Sublime's own output window.
Thanks in advance