Ошибка cannot open output file debug permission denied

I compile a Qt program with C++, and I got this error message:

cannot open output file debugserbest.exe: Permission denied
collect2: ld returned 1 exit status

What are these command’s meaning?

How do I get rid of these errors?

Pika Supports Ukraine's user avatar

asked Jul 27, 2010 at 10:29

zibib's user avatar

2

Most likely cause: serbest.exe is still running. Check with TaskManager.

answered Jul 27, 2010 at 10:31

H H's user avatar

H HH H

262k30 gold badges329 silver badges514 bronze badges

4

It says the current user is not having enough right to write onto the debug folder. Check whether you can create a new file in the folder as referred to.

answered Jul 27, 2010 at 10:31

Kangkan's user avatar

KangkanKangkan

15.2k10 gold badges70 silver badges113 bronze badges

1

run your compiler software as admin. choose your compiler on start menu > right click and run as admin. you wil not probably see any permission denied errors.

answered Jun 29, 2013 at 17:32

pradeep's user avatar

Sometimes this error caused because of your antivirus added this file in the limited group.
This helped me!

answered Jun 19, 2018 at 8:45

Ura's user avatar

0

8 / 8 / 0

Регистрация: 05.11.2011

Сообщений: 81

1

Не получается собрать проект

08.04.2012, 11:53. Показов 11340. Ответов 7


Студворк — интернет-сервис помощи студентам

Не могу собрать проект по теме «Qt-руководство для начинающих».Пункт 2.2.
Выводит 2 ошибки:
cannot open output file debugfirst.exe:Permission denied.
collect2:id returned 1 exit status.Помогите



0



Programming

Эксперт

94731 / 64177 / 26122

Регистрация: 12.04.2006

Сообщений: 116,782

08.04.2012, 11:53

7

159 / 152 / 50

Регистрация: 03.08.2011

Сообщений: 299

Записей в блоге: 14

08.04.2012, 12:00

2

А у вас экзешник, случаем, не запущен?



1



8 / 8 / 0

Регистрация: 05.11.2011

Сообщений: 81

08.04.2012, 12:09

 [ТС]

3

Какой exe-шник?Я открыл Диспетчер задач и не нашёл first.exe.
Когда удаляю exe-шник и собираю заново-всё получается.
Иначе никак. Объясните мне кто-нибудь,почему это так,а то я никак не пойму



0



Почетный модератор

11309 / 4283 / 439

Регистрация: 12.06.2008

Сообщений: 12,342

08.04.2012, 12:19

4

Возможно, какой-то процесс его открывает для чтения или просто блокирует. Может, антивирус глючит. Посмотри через программу Unlocker, какой процесс занимает твой exe’шник.



0



35 / 35 / 1

Регистрация: 02.03.2012

Сообщений: 117

08.04.2012, 12:50

5

Кстати, у меня тоже был такой косяк, когда ставил себе 4.7.0. Постоянно приходилось удалять exe файл, чтобы откомпилить снова



0



8 / 8 / 0

Регистрация: 05.11.2011

Сообщений: 81

08.04.2012, 13:02

 [ТС]

6

kniferko, а как ты его решил?



0



35 / 35 / 1

Регистрация: 02.03.2012

Сообщений: 117

08.04.2012, 13:29

7

честно говоря, как-то само решилось по себе через недельку другую после очередного запуска компа



1



Автор FAQ

2732 / 1428 / 89

Регистрация: 08.09.2011

Сообщений: 3,746

Записей в блоге: 1

08.04.2012, 15:40

8

вероятнее все дебагер не выгрузился и хоть процесса нет дебагер ссылается на ехе файл и в результате креатор не может его заменить на новый скомпилированый



1



5th December 2019, 23:03


#1

Default cannot open output file debugFilename: Permission denied

On Windows 7 I was using Qt 5.12.6 with Qt Creator 4.10.2 IDE and compiling with MinGW 64-bit utilizing the provided qmake, on Windows 7. I ran into an interesting situation.

When attempting to compile and debug a project, Qt Creator started giving the following message

:-1: error: cannot open output file debugTestFlight.exe: Permission denied
collect2.exe:-1: error: error: ld returned 1 exit status


Assuming that the program somehow was not shut down correctly, I could not find any reference to the program using the task manager, so I attempted to see if it would run stand-alone, which just resulted in the following…

Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item.

This appeared odd seeing as I have full administrative permissions and I should be the owner 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…

1 Right clicked the file
2 Selected properties
3 Selected the security tab which then caused a new window to pop up with the following statement…

To continue, you must be an administrative user with permission to view this object’s security properties

4 Clicked Continue

A window then popped up displaying a message stating that I do not have permission to view the object’s security properties along with a section that should have displayed the owner information and another section with a list of users. However in the current owner section, it simply stated…

Unable to display current owner. To try taking ownership of the object select an account from the list, and then click OK.

5 There were two accounts in the list. Both of them were mine and they both had admin privileges. I attempted to change the owner using both accounts and each time a window popped up and sated…

Unable to set new owner on file name.
Access is denied


without any further explanation.

I’m somewhat confused on this one since I have full admin privileges and it doesn’t let me change, access, or even delete the file. I have run the Build->Clean All and Build->Run qmake options from the menu with out any effect on the outcome. So I rebuilt the whole program and attempted it again.

The rebuilt program compiled and ran just fine and did not exhibit any of the signs or problems experienced on prior attempts. When I checked the executable in the debug directory I was able to access the parameters and security settings of the file and I was listed as the owner. So after some minor 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 attempt to compile it again.

Unfortunately, during the compile the same issues were reported by Qt Creator as with the prior build…

:-1: error: cannot open output file debugTestFlight.exe: Permission denied
collect2.exe:-1: error: error: ld returned 1 exit status


In addition to searching in the Task Manager and Process Explorer I’ve rebuilt this program several times, changed directories, scoured the operating system environment for anomalies, and shut down any other programs that were running. and yet I’m still getting the same results. I searched for and found a multitude of similar situations on several programming boards (including this one) but there have been no satisfactory solutions with the exception that some individuals seem to have found that turning on “Application Experience” in Windows seems to resolve the issue. Unfortunately, this appears to be a feature that is not in Windows 7. I’ve run out of things that I know to check for. I strongly suspect that this may be a problem minGW or maybe Windows, but if anyone has any insight on this issue, it would be highly appreciated.


6th December 2019, 17:23


#2

Default Re: cannot open output file debugFilename: Permission denied

I have occasionally come across a similar problem using Visual Studio in Windows 10, 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 get released. In VS and probably in Qt, builds can be multithreaded, so there could be a bug resulting in a race condition or other fault that sometimes keeps the lock from being properly released.

With Visual Studio, closing and restarting VS has often cleared things up. Sometimes it has taken a reboot if there is some dangling VS process left behind after closing it.

There is a new security feature that has recently been added to Windows 10, which prevents apps from writing to or changing files in certain «protected» directories without explicit permission, including Microsoft’s own programs, like Visual Studio and MS Office that are now blocked from updating the default options files in your App Data folders. Your choices are either to turn it off completely and risk a malware attack, or to go into Window security for every program you use, find out where it is trying to write, and add it to the list of allowed programs. It’s even worse with programs like OpenOffice, which consist of a driver program that fires off child programs to handle each specific document type. You have to add the driver and each of the child programs, individually and manually to the list. Major PITA. My solution has been to change the parameter directories to something I can control if possible.

<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click «Go Advanced» and then the «#» icon to insert the tags. Paste your code between them.


The following user says thank you to d_stranz for this useful post:

Corny (6th December 2019)


22nd March 2021, 14:38


#3

Default Re: cannot open output file debugFilename: Permission denied

Good morning Earth,

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, 15:43


#4

Default Re: cannot open output file debugFilename: Permission denied

Yes. After this happened to me several times, I discovered that anti-virus software (Malwarebytes in my case) was incorrectly classifying the exe file as malware and was quarantining it. So the file would be written and as soon as the debugger would try to run it, the anti-virus software would delete it. I could watch the file appear in the output folder, then just as quickly it would disappear. For some reason, debug mode 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, because you might forget to turn it back on after you have finished debugging.

<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click «Go Advanced» and then the «#» icon to insert the tags. Paste your code between them.


Topic: «Cannot open output file»  (Read 47801 times)

I know there are countless threads about this, though I assure you I’ve sifted through each of them and not found any answers to my problem.

Cannot open output file bindebugFirst Project.exe Permission Denied

I get this build error message ONLY after I’ve built once, (the first time always works) and then changed something. The next time I try to build I get that message.

is the message I’m getting. I’ve reinstalled codeblocks AND my moved my project folder multiple times, I’ve changed permissions, messed with user account controls, made Ld.exe in the codeblocks folder run as an administrator, checked in task manager and sysinternals for a double process of my code, etc.

None of these have worked, so if any of you have any ideas I’d love to hear them.


Logged


Update:

With task manager and sysinternals up, there are no conhost processes running when I am getting this error, there are also no «firstproject.exe» or whatever, BUT after about 5 minutes (5 long minutes) I am able to build again… It’s acting as though it’s taking a minute to close the process down but there is indeed none running.

Strange


Logged


You did not really tell much about your installation.
I assume it is windows (exename and name of the tools).

This might be some stupid security software that kicks in and blocks the exe.


Logged


You did not really tell much about your installation.
I assume it is windows (exename and name of the tools).

This might be some stupid security software that kicks in and blocks the exe.

Windows 7 professional
64 bit

I’ve killed all antivirus and security exes in the task manager, and AVG is completely uninstalled (downloaded a clean AVG completely tool)

Still no luck.


Logged


probably a directory where you don’t have write access? Try in your home directory…


Logged


Update

It seems to work 75% of the time if I keep sysinternals process explorer up and directly kill the process each time before I hit any key to end

What a pain..

« Last Edit: June 18, 2014, 06:25:01 am by lwe1389 »


Logged


this is 300% a user problem… I have two things in mind:
1) Are you sure that you don’t have any antivir, adaware, firewall or windows security installed what can block the access to your program?
2) Are you sure, that it is not a coding error, probably your application  crashes or hangs. (is there a drwat*.exe in the process tree?)

and directly kill the process each time before I hit any key to end

this screams for a coding error (deleting or not deleting a pointer…). Have you tried to debug your code?

greetings


Logged


It isn’t a coding error, i’m following c + + primer, buckys tutorials, and a few other resources. A majority of the code is copy and paste or nearly identical to the sources aforementioned. It’s day 3 of self learning and i’m only just starting to write my own (which obviously have mistakes at first) but the problem has persisted since the second I installed codeblocks. (if I change «hello world» to «hello Lance», it happens»

I’ll look deeper into security software but I don’t know if that’s it


Logged



Logged



Logged

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.

When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org


Well, I’ll post a conjecture.

You can’t write to the binary file of a program as long as the program is running, even as administrator. You’ve already suspected something like that.
I remember that one of the tools of the «Sysinternals Suite» could observe and log if a file has been opened by a process and if it is still open. Perhaps it is
the «Process Monitor». I don’t remember exactly and I don’t have a Windows System at hand now to check it.

Try to find out which process keeps your «First Example.exe» open and you should be one step towards a solution.

In spite of that turning on full compiler logging and posting the output should also do no harm  ;D

You may grab the «Sysinternals Suite» from here: http://technet.microsoft.com/en-us/sysinternals/bb842062.aspx


Logged


You can Crtl+C your script and then, make a same project with the same title in the same file. That way, most of the times, you will get rid of your error and not erase the code, but sometimes, the code could be turned into the preview(code that is always made), so you would need to Ctrl+C it.
Please understand if my English is bad. I’m a Korean…


Logged


Что делать если возникают ошибки линковки?

Здравствуйте. У меня вопрос. Почему вылезает эта фигня, после плохой сборки и потом от нее не избавиться, даже если код абсолютно правильный. Ошибки:
1):-1: ошибка: cannot open output file debugProject1.exe: Permission denied
2)collect2.exe:-1: ошибка: error: ld returned 1 exit status

Вроде бы это ошибка линковщика. Если перезапустить комп, то проблемы исчезнут. Как решить эту проблему.Очень напрягает. Большое спасибо.


  • Вопрос задан

    более трёх лет назад

  • 600 просмотров

Пригласить эксперта

Ошибка означает что линковщик не может записать бинарный файл.
Файл занят либо ОС которая достает из него значок, или если программа запущена.
Посмотрите в процессах и прибейте его.
А так же не оставляйте в Explorer открытой папку где видно бинарник.


  • Показать ещё
    Загружается…

13 июн. 2023, в 14:38

1000 руб./за проект

13 июн. 2023, в 14:15

50000 руб./за проект

13 июн. 2023, в 14:03

5000 руб./за проект

Минуточку внимания

Возможно, вам также будет интересно:

  • Ошибка cannot open hasp driver
  • Ошибка cannot open file fsgame ltx check your working
  • Ошибка cannot open file for saving
  • Ошибка cannot modify a read only dataset
  • Ошибка cannot open file check your working folder

  • Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии