Sublime Forum

Cant compile c++ code in Sublime Text 3

#1

I wrote a code in c++ and ran it in online gdb debugger and it ran perfectly fine over there but when I ran the same code in Sublime text 3 for various test cases, it started giving this error. Now I am getting really frustrated why this error pops up.
So, good human, please help me by fixing it.

[WinError 2] The system cannot find the file specified
[cmd: [‘bash’, ‘-c’, ‘g++ -std=c++0x ‘C:\Users\Dell\Desktop\CPP Programs\a.cpp’ -o ‘C:\Users\Dell\Desktop\CPP Programs/a’ && xterm -e bash -c ‘“C:\Users\Dell\Desktop\CPP Programs/a” ; read’’]]
[dir: C:\Users\Dell\Desktop\CPP Programs]
[path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\MinGW\bin;“C:\Users\Dell\AppData\Local\Microsoft\WindowsApps;”;C:\Users\Dell\AppData\Local\Programs\Microsoft VS Code\bin;C:\MinGW\bin;]
[Finished]

0 Likes

#2
C:\Users\Dell\Desktop\CPP Programs/a

Doesn’t look right.

0 Likes

#3

Your setup looks like you’re on Windows, but the command that the build system is executing looks more Linux related in that it’s using xterm as a terminal, which is generally not something that’s available on Windows without a bunch of extra work.

Specifically the error that you’re seeing would seem to indicate that bash is not something that you have installed, or it’s not on the PATH; thus when Sublime asks Windows to execute it, Windows responds to say that it can’t because it can’t find it.

As a first step, assuming you have MinGW properly installed (it appears in your PATH so I would assume that it is) I would try using the C++ Single File build that ships with Sublime to see if that can compile and run your program.

If that works, then we can proceed with how to modify that build to do what you want. If not, then the problem is a little deeper.

0 Likes