6

While building a Flutter app for Windows in debug mode, this error is occuring. flutter doctor -v gives normal output. What might be the cause of this ?

Launching lib\main.dart on Windows in debug mode...
lib\main.dart:1
LINK : fatal error LNK1168: cannot open F:\{project-name}\build\windows\runner\Debug\{project-name}.exe for writing [F:\{project-name}\build\windows\runner\{project-name}.vcxproj]
Exception: Build process failed.
Exited (sigterm)
aihamhasan
  • 479
  • 1
  • 6
  • 11
  • I had the same error. A restart of VSCode helped. To summarise: 1. Close VSCode 2. Close related processes (i.e vscode.exe, dart.exe) 3. Start VSCode 4. If above did not help, run `flutter clean` – Yuriy N. May 12 '23 at 12:06
  • It happened again. This time the reason was that the Windows application myapp.exe was still running in the background. After killing the process everything works again. – Yuriy N. Jun 05 '23 at 11:28

1 Answers1

4

The issue got resolved after running flutter clean, but i dont know the main cause of this problem

aihamhasan
  • 479
  • 1
  • 6
  • 11
  • 2
    It's due to the `example.exe` file being utilized somewhere. The OS may have been keeping the process alive for some reason even after you believed you closed it. – Christopher Moore Apr 01 '21 at 14:11
  • 1
    Had the same problem. After hours of research, I figured out it was because.....of my antivirus. – matteoh Aug 16 '21 at 17:02
  • 4
    In my case, the program stuck in background, and everything is fine after I deleted It from task manager. – Tokenyet Mar 17 '22 at 13:52
  • I had a different error, namely `LNK 1112`. It also got resolved with `flutter clean`. So I think any LNK errors you get you can just clean project and it works. – hman_codes Jan 13 '23 at 17:41
  • When a program fails with a runtime error, the exe may still be running in the background. So it must be stopped in task manager so that the compiler (vscode) can replace the exe. Also a good idea to stop and start vscode. – Steven Green Apr 16 '23 at 05:53