Hello all,
Please bear with me - I am facing a really weird issue. I will try to be as exact as possible.
TL;DR - Compilation is successful only once, then every subsequent attempt (with any minor code change) fails with error (see below). Can only recompile if I manually go and delete .exe file (can do it as simple user, no need for elevated cmd). Running codeblocks as admin has same result. Antivirus is disabled. Fresh install CodeBlocks 20.03, MINGW64 bundle. ---
I am using a fresh install of CodeBlocks 20.03 (installed with the bundled MinGW64 compiler). OS is Windows 10 - 64bit.
I have been using Codeblocks without problem for 4-5 years now (version 17.12 - I just uninstalled and installed 20.03 trying to fix my proboem, but as I expected, it didn't work).
Suddenly, today, whenever I create a new file (just a simple File -> New -> Empty file),
save it as test.c for example, write a simple hello world c program - when I compile it (or compile/run)
everything works fine.
However, when I make any change to the code, for example change the printout to "hello world2", when trying to recompile I get:
||=== Build file: "no target" in "no project" (compiler: unknown) ===|
ld.exe||cannot open output file C:\tmp\test.exe Invalid argument|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
Settings -> Compiler -> ToolChain Executables shows correct path.
I googled around
extensively for a solution ..
- I have my antivirus disabled, this cannot be an issue.
- I also searched for processes, both with task manager, and various powershell commands/applets that list all processes, sorted by datetime etc, could not really identify a process that 'stays alive' and causing problems as some people seem to suggest.
- I also stumbled accross a similar issue,
described here, that talks about enabling an 'application experience' service in windows that could cause issues - no luck there, service is enabled in my system (as it should be)
Now, I finally found kind of a 'solution', or actually more a sign of what the problem is.
If I manually go to a command prompt (not even an elevated one) and delete created .exe file, for example test.exe in the example above, then codeblocks can successfully compile (and run) the updated code, again only once though. Recompiling after a change gives the same error, and I have to manually delete new .exe file etc...
I have cleared my PATH environment because I had another version of GCC sitting there and thought this might (somehow?) create an issue..
I have tried to run Codeblocks as administrator just in case .. Exact same thing happens ..
The strange thing is that all this just happened 'randomly' - I mean I didn't change anything in windows or codeblocks .. It just happened today. Could it be a Windows update that messed something up?
Only thing I tried to do that might be relevant (although I cant understand how) is that I tried to setup VS Code to compile/run C programs - it did so successfully, but shows same behaviour - compiles and runs only once, then I have to go and manually delete .exe file in order for it to run again, and in VS code's case, I need an elevated prompt to delete the .exe .. I couldn't bother with that, and turned back to CodeBlocks (which I actually like to be honest) only to find this weird error here too.
Although it seems the vs code setup messed up things, I suspect it might be a coincidence, since I hadn't run CodeBlocks in some time, perhaps a windows update messed up something and I just had not been aware of it .. Maybe I 'm wrong and vs code did mess something up in my system..
Any help would be GREATLY appreciated .. I 've been fighting with this for4-5 hours now and really don't know what to do .. Unfortunately I don't have windows restore points, I would have tried that too.
Again pointing out that uninstall and fresh install of CodeBlocks 20.03 did nothing - it seems to be a weird OS issue? Codeblocks doesn't have the right to overwrite the .exe file created?
I would really appreciate any help and of course I m looking forward to any suggestions in order to try anything ..
thanks - sorry for the length of this message..
PS - I should point out that even successful compilation, still prints:
||=== Build file: "no target" in "no project" (compiler: unknown) ===|
||=== Build finished: 0 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
So I guess the 'compiler:unknown' is a "standard" message, although a bit weird - but that's not the problem.. Again I verify that settings->compiler->toolchain executables shows right path (and program compiles and runs (i see output) on first time OK, as well as every time I go and delete the .exe file...
I 'll add one more detail I just noticed, although this is way too big already..
If I only compile - then everything works fine. I mean, I can make changes to the code, and
simply compile, everything is successful (no errors) and I see updated timestamps on .o object file, .exe and of course .c file. Problem starts happening as soon as I click 'run'
even once on codeblocks - first time the program runs, terminal opens, I see output, but then every subsequent attempt to even simply compile (without even any changes) results in the aforementioned error.