Cannot rerun C++ code after compiling files are created [closed]

2 weeks ago 16
ARTICLE AD BOX

I am learning how to code in C++ with VSCode in Windows. I am trying to print a "Hello world". I followed along the VSCode tutorial and, after I did that, wrote a small program that printed "Hello world". It worked fine.

However, after I ran my program once, VSCode created a bunch of files:

helloworld.exe
helloworld.ilk
helloworld.obj
helloworld.pdb
vc140.pdb

As well as a .vscode folder containing a JSON file. I understand those files are needed because the code needs to be compiled. However, after I run my code twice, I receive a popup error:

The preLaunchTask 'C/C++: cl.exe build active file' terminated with file code -1

This error disappears when I erase the files created by VSCode and rerun the code.

How can I fix this?

Edit: here is my code:

´#include <iostream> using namespace std; int main(){ cout << "Ola mundo"; cout << "\noi"; return 0; }´

I am running by simply pressing the 'run' button in VSCode. After the first run, the result is exactly the expected:

´Ola mundo oi´

After the second run, this error is shown in the Problems section:

Erro PDB inesperado; LIMIT (12) 'C:\Users[...]\olamundo.pdb'

When I click 'Debug Anyway', I receive the following popup message:

'launch: program "C:\Users[...]\olamundo.exe" does not exist.'

Which indeed seems to be the case: the .exe file is no longer in my folder.

Read Entire Article