Having trouble compiling in VS Code terminal, which is Windows Powershell

Question:

When I right click Run code, and have run in terminal on in my user settings I get these errors.

I have been compiling fine up until today, and I did some googling and started typing my own commands into the terminal instead of just running code.

I started replacing the && with -and and get a different problem. This is what the command looks like now.

This is the error I get.

I am using the GNU open source compiler, this is the first issue I have had with compiling since I realized you have to save before you compile. I am running a simple string that changes all the characters to X from a string that is read from terminal from C++ Primer program. Any help would be appreciated.

Answer:

I had the same problem, I believe it is caused by the new VS code version 1.35.
I tried downgrading to 1.34 and compiling and running c++ worked again.

The old version seems to run the code with a different command:

“cd $dir ; if ($?) { g++ $fileName -o $fileNameWithoutExt } ; if ($?) { .\\$fileNameWithoutExt}”

in your case it would look like:

cd “c:\Users\Josh\Documents\Programming\Learning to Program\” ; if ($?) { g++ Exercise36.cpp -o Exercise36 } ; if ($?) { .\Exercise36}

For me using this comand compiling and running works in the new VS version aswell.

Source:

Having trouble compiling in VS Code terminal, which is Windows Powershell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply