So I’m trying to build a C++ program on Sublime Text 3 but I keep getting a variety of issues.
I have HelloWorld.cpp
below, in directory C:\Users\kevin\Desktop\C++
:
#include <iostream>
#include <string>
int main(){
std::cout << "Hello World!" << std::endl;
std::cout << "Hello World!" << std::endl;
std::cout << "Hello World!" << std::endl;
std::cout << "Hello World!" << std::endl;
return 0;
}
First try: build and run with built-in C++ Single File
generates this error:
Access is denied.
[Finished in 2.6s with exit code 1]
Second try: building with build file CPP.sublime-build:
{
"cmd":["bash", "-c", "g++ -std=c++14 -Wall '${file}' -o '${file_path}/${file_base_name}' && '${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", "g++ -std=c++14 '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
}
]
}
[WinError 2] The system cannot find the file specified
[cmd: ['bash', '-c', "g++ -std=c++ -Wall 'C:\\Users\\kevin\\Desktop\\C++\\HelloWorld.cpp' -o 'C:\\Users\\kevin\\Desktop\\C++/HelloWorld' && 'C:\\Users\\kevin\\Desktop\\C++/HelloWorld'"]]
[dir: C:\Users\kevin\Desktop\C++]
[path: C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;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\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Bitvise SSH Client;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Java\jdk1.8.0_121\bin;C:\Program Files (x86)\Skype\Phone\;C:\MinGW\bin;C:\Users\kevin\AppData\Local\Microsoft\WindowsApps;]
[Finished]
I’ve installed MinGW, and have edited my environmental PATH variable to include C:\MinGW\bin
.
Additional details: Running Windows 10, x64 based PC.
Any ideas?