Cannot Open Output File Permission Denied

6th December 2019,00:03
#one

cannot open output file debug\Filename: Permission denied
On Windows seven I was using Qt 5.12.6 with Qt Creator 4.10.2 IDE and compiling with MinGW 64-scrap utilizing the provided qmake, on Windows vii. I ran into an interesting situation.
When attempting to compile and debug a project, Qt Creator started giving the post-obit message
:-1: mistake: cannot open output file debug\TestFlight.exe: Permission denied
collect2.exe:-1: fault: error: ld returned 1 exit status
Assuming that the programme somehow was not shut down correctly, I could non discover whatever reference to the program using the task director, so I attempted to see if information technology would run stand up-alone, which just resulted in the following...
Windows cannot access the specified device, path, or file. You may not accept the appropriate permissions to access the item.
This appeared odd seeing as I have full authoritative permissions and I should exist the possessor of the file. So I attempted to access the permissions of the file to see what exactly was going on by highlighting the file and taking the following steps...ane Right clicked the file
2 Selected properties
iii Selected the security tab which then caused a new window to pop up with the following argument...
To go along, you must exist an administrative user with permission to view this object'south security properties
4 Clicked ProceedA window then popped up displaying a message stating that I exercise not have permission to view the object’s security properties along with a section that should take displayed the owner information and another section with a listing of users. Withal in the current owner department, it simply stated...
Unable to brandish current owner. To effort taking ownership of the object select an business relationship from the list, and so click OK.
5 At that place were two accounts in the listing. Both of them were mine and they both had admin privileges. I attempted to change the owner using both accounts and each fourth dimension a window popped up and sated...
Unable to set up new possessor on file proper name.
Access is denied
without any farther explanation.I’m somewhat dislocated on this one since I take full admin privileges and information technology doesn’t let me change, access, or fifty-fifty delete the file. I have run the Build->Clean All and Build->Run qmake options from the menu with out whatever effect on the outcome. So I rebuilt the whole program and attempted information technology once again.
The rebuilt program compiled and ran just fine and did not showroom any of the signs or problems experienced on prior attempts. When I checked the executable in the debug directory I was able to admission the parameters and security settings of the file and I was listed every bit the owner. So later some pocket-sized coding changes, I checked the executable file in the debug directory again, and everything was as it should be. I felt it was fine to go ahead and effort to compile information technology again.
Unfortunately, during the compile the same issues were reported by Qt Creator as with the prior build...
:-i: error: cannot open output file debug\TestFlight.exe: Permission denied
collect2.exe:-1: fault: mistake: ld returned one get out condition
In addition to searching in the Task Manager and Process Explorer I’ve rebuilt this program several times, inverse directories, scoured the operating system surroundings for anomalies, and shut down any other programs that were running. and yet I’m all the same getting the same results. I searched for and found a multitude of similar situations on several programming boards (including this one) but at that place have been no satisfactory solutions with the exception that some individuals seem to have found that turning on “Awarding Experience” in Windows seems to resolve the upshot. Unfortunately, this appears to exist a feature that is not in Windows seven. I’ve run out of things that I know to check for. I strongly doubtable that this may be a problem minGW or possibly Windows, simply if anyone has any insight on this upshot, it would exist highly appreciated.
sixth Dec 2019,eighteen:23
#ii

Re: cannot open output file debug\Filename: Permission denied
I have occasionally come across a similar trouble using Visual Studio in Windows ten, and so I don't think it is specifically a Qt Creator problem. What I surmise happens is that the build locks the output file and that this lock doesn't become released. In VS and probably in Qt, builds can be multithreaded, then in that location could be a bug resulting in a race status or other fault that sometimes keeps the lock from being properly released.
With Visual Studio, closing and restarting VS has oft cleared things up. Sometimes it has taken a reboot if there is some dangling VS process left backside after closing information technology.
In that location is a new security feature that has recently been added to Windows 10, which prevents apps from writing to or irresolute files in certain "protected" directories without explicit permission, including Microsoft'south own programs, like Visual Studio and MS Office that are now blocked from updating the default options files in your App Information folders. Your choices are either to turn information technology off completely and chance a malware attack, or to go into Window security for every program you employ, notice out where information technology is trying to write, and add it to the list of allowed programs. Information technology'due south even worse with programs like OpenOffice, which consist of a commuter programme that fires off child programs to handle each specific document type. You accept to add the driver and each of the kid programs, individually and manually to the list. Major PITA. My solution has been to change the parameter directories to something I tin can control if possible.
<=== The Great Pumpkin says ===>
Delight utilise CODE tags when posting source code then information technology is more readable. Click "Go Advanced" and so the "#" icon to insert the tags. Paste your lawmaking betwixt them.
The following user says thank you to d_stranz for this useful post:
Corny (sixth December 2019)
22nd March 2021,15:38
#3

Re: cannot open output file debug\Filename: Permission denied
Good morning Globe,
I had the same issue on my Windows 10 box, and the guilty was the antivirus : by disabling temporary my Kaspersky antivirus, I was able to successfully compile and run my Qt project.
Bonjour chez vous !
JPL
22nd March 2021,16:43
#4

Re: cannot open output file debug\Filename: Permission denied
Yep. Afterward this happened to me several times, I discovered that anti-virus software (Malwarebytes in my case) was incorrectly classifying the exe file equally malware and was quarantining it. And then the file would be written and as soon equally the debugger would try to run it, the anti-virus software would delete it. I could picket the file appear in the output binder, then just as quickly information technology would disappear. For some reason, debug manner Qt apps seem to trigger anti-virus software occasionally.
The solution was to "white-list" the exe so Malwarebytes would ignore it. I don't recommend totally disabling your anti-virus software, considering you might forget to turn it dorsum on afterward you take finished debugging.
<=== The Slap-up Pumpkin says ===>
Delight utilize CODE tags when posting source code and so information technology is more readable. Click "Become Advanced" and and so the "#" icon to insert the tags. Paste your code between them.
Source: https://www.qtcentre.org/threads/70626-cannot-open-output-file-debug-Filename-Permission-denied