Have you tried pressing a key to close the console?
The "No project/No target/Unknown compiler" message has no sense, and
ld.exe||cannot open output file C:\tmp\test.exe Invalid argument|
means something is corrupted.
Go to Settings->Compiler->Other settings and select "Full command line" in Compiler logging. Then do a full rebuild and post the result here in code tags (the # above the edit window).
Thanks for your help. I am trying to provide what you requested.
I checked compiler -> settings -> other settings, compiler logging was already in 'full command line'.
I create a new file, test3.c. It contains a simple printout.
I compile the .c file first (simple compile, not build and run). In codeblocks build log i get:
-------------- Build file: "no target" in "no project" (compiler: unknown)---------------
gcc.exe -c C:\Users\thomas\test3.c -o C:\Users\thomas\test3.o
gcc.exe -o C:\Users\thomas\test3.exe C:\Users\thomas\test3.o
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Then I do build & run. Program executes succcessfully, a terminal window opens and I see the results of the printf.
Build log in codeblocks shows:
-------------- Build file: "no target" in "no project" (compiler: unknown)---------------
gcc.exe -c C:\Users\thomas\test3.c -o C:\Users\thomas\test3.o
gcc.exe -o C:\Users\thomas\test3.exe C:\Users\thomas\test3.o
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Checking for existence: C:\Users\thomas\test3.exe
Executing: '"C:\CodeBlocks/cb_console_runner.exe" "C:\Users\thomas\test3.exe"' (in 'C:\Users\thomas')
Set variable: PATH=C:\CodeBlocks\MinGW\bin;C:\CodeBlocks\MinGW;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\PuTTY;C:\Program Files (x86)\Calibre2;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\MinGW64\bin;C:\Program Files\dotnet;C:\Program Files\nodejs;C:\Program Files (x86)\dotnet;C:\Program Files\GitHub CLI;C:\Program Files\Git\cmd;C:\Users\thomas\AppData\Local\Programs\Python\Python311\Scripts;C:\Users\thomas\AppData\Local\Programs\Python\Python311;C:\Users\thomas\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Java\jdk1.8.0_191\bin;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.3.2\bin;\;C:\Users\thomas\AppData\Local\Android\Sdk\platform-tools;C:\Users\thomas\AppData\Roaming\npm;C:\Program Files (x86)\Nmap;c:\Users\thomas\aliases
This is the terminal window:
1111
Process returned 0 (0x0) execution time : 1.822 s
Press any key to continue.
(the only code inside the test3.c file is a
I close terminal window.
If I do another Build&Run (without changing anything in the code), I get the error. Build log shows:
-------------- Build file: "no target" in "no project" (compiler: unknown)---------------
gcc.exe -c C:\Users\thomas\test3.c -o C:\Users\thomas\test3.o
gcc.exe -o C:\Users\thomas\test3.exe C:\Users\thomas\test3.o
C:/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot open output file C:\Users\thomas\test3.exe: Invalid argument
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Could it be that PATH shows two different entries for MINGW compiler, one ending at the /bin directory and one in the parent directory, or is that completely irrelevant?
OK .. I checked that tool ..
I reboot, clean machine, I create a new file, test.c.
I build and run, program compiles and runs successfully, terminal window is open (I don't close it yet).
I open up built-in Resource Monitor - screenshot here (https://imgur.com/a4ECDv2).
I see the process cb_console_runner.exe (pid=15172). Searching through handles, i see multiple entries, all same PID. To be honest, I can't fully understand handles 'do'.. All have same PID so it's sort of different references to the same process in different parts of the OS?
By the way, task manager obviously shows same process (same id of course, although i did not capture it with screenshot) - screenshot here (https://imgur.com/gT1bfB9).
Now, I close the terminal window, and as expected the process disappears from task manager, and in Resource Monitor it shows as 'terminated' (screenshot here (https://imgur.com/HQ0RAa7) - also grayed out, disabled) and when I click on the processes window, it kind of 'refreshes' and the process completely disappears from the processes list. Sorting with PIDs, there is no process with pid 15172 anymore. I can't see anything on bottom window with 'handles' either..
Now, I try to build & run again, only to get the same error:
-------------- Build file: "no target" in "no project" (compiler: unknown)---------------
gcc.exe -c C:\Users\thomas\test.c -o C:\Users\thomas\test.o
gcc.exe -o C:\Users\thomas\test.exe C:\Users\thomas\test.o
C:/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot open output file C:\Users\thomas\test.exe: Invalid argument
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Interestingly, I try to manually delete .exe file, and I get "action can't be completed because the file is open in another program".
I close CodeBlocks (just in case) - same message, action can't be completed...
In the past, I could delete .exe files manually ...
Also - irrelevant probabaly - but I performed a CHKDSK on windows, it found that it needed to fix some errors, rebooted, performed thorough CHKDSK, it said it fixed stuff, nothing changed ..
I am searching on how to find that 'other program' that holds a lock on the .exe file - but everything points to checking task manager, killing the process etc - but I cant find any process that deals with it once the terminal window is closed. Process Monitor has no handles on previous PID 15172 ... all processes seem legit and irrelevant to that previous executable ...
I 'm lost... any ideas would be greatly appreciated ...
Please try to create Project via project wizard initially (menu "File - New - Project") and then add file or files to compile into project. Then try to rebuild it.
Sorry, I was posting a reply and did not see your message in time.
I did try this just now, created a C project, and then ran the main.c file that comes to it. It compiles and runs successfully first time. Second time, I get the same error. See log: (notice the compiler is now reported, as it's a project not a single file, as someone mentioned earlier).
-------------- Build: Debug in test (compiler: GNU GCC Compiler)---------------
gcc.exe -Wall -g -c C:\tmp\askiseis\test\main.c -o obj\Debug\main.o
gcc.exe -o bin\Debug\test.exe obj\Debug\main.o
C:/CodeBlocks/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot open output file bin\Debug\test.exe: Invalid argument
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 0 warning(s) (0 minute(s), 0 second(s))
PS - Please dont be confused by the 'tmp' directory name, it's the name of a course, it's not a 'temp' directory .. it's just a regular directory that I created.