Devin
Devin

Reputation: 1

Why does the .exe file become locked after compiling?

If I compile Test.cpp with g++ -o Hello_World Test.cpp, I get Hello_World.exe. If I run g++ -o Hello_World Test.cpp again, I get a collect 2 error:

Collect 2 error during compiling

The goal is to compile Test.cpp into Hello_World.exe (but two times in a row). Here are my steps:

  1. In a terminal: g++ -o Hello_World Test.cpp
  1. Test with ./Hello_World.cpp
  1. Compile again: g++ -o Hello_World Test.cpp
  1. If I right click on Hello_World.cpp and try to delete it, I get an error saying The action cannot be completed because the file is open in another program. I tried to use resmon.exe to see the running .exe files, and I couldn't figure out what was using Hello_World.exe, and Hello_World.exe was not open itself. If I use rm Hello_World.cpp, I get an error saying I don't have permission.

If anyone has an idea as to what might be happening, I would greatly appreciate it.

Upvotes: 0

Views: 94

Answers (1)

Chukwujiobi Canon
Chukwujiobi Canon

Reputation: 4091

If anyone has an idea as to what might be happening, I would greatly appreciate it.

Well it’s simple. The application is running in the background. You can check your TaskManager and kill it from there.

What exactly causes the application to keep running in the background will need more investigation to find out.


The most common reason this happens in Sublime is when you are running an interactive application. Sublime doesn’t forward any input that you type into the output panel to your running program, so it’s effectively hung forever in the background waiting for input you can’t provide.

Upvotes: 1

Related Questions