cannot open output file permission denied

So I keep getting this error when trying to compile C++ code using CodeBlocks.

cannot open output file [filename.exe] permission denied

It only started today, and it’s sporadic and inconsistent. It usually goes away if I shut CodeBlocks down and restart the project, but not always. Sometimes it even goes away when I just press F9 (build & run) several times. I always check Task Manager, but there are never any .EXEs running with my file’s name, or anything related to it.

I’ve also noticed that if this problem occurs and I then try to delete the .EXE manually or otherwise interact with it, Windows tells me I need administrator permission to do so (this is a private PC, and as far as I know I am an administrator on it).

The first time it occurred, the only thing I had added to the code beyond what was in the previous version was a debugging report sent to cout — hardly anything arcane. It sometimes occurs even when no code was changed from a previous version.

What could this be? It’s not game-breaking, yet, but it’s irritating and I’d rather it didn’t get worse.

a Z d hqj P b kxMtM y FqSt nW F V o Hfl r XC g Rawi e eNPRb tJKgB o a f LmZ NWEG E JlkW m G p RGr i d r CnieT e O s OwmYk : LQg DWlnM B YjBK u lZMAd i tS l AZovC d mt KcLB a eoWr pXE C R i LTzj t S y OlZuI

Answer Wiki

I have the Eclipse IDE and I am also facing this same problem.

And I tried as I mentioned as follows, it works :

Select your source code that you have compiled -> then click CLEAN PROJECT -> the source build will be repeated. Then you may be get rid of that fatal error or ‘Cannot open output file permission denied’.

so I’m completely new to Ubuntu. I’ve set up a shared folder with a few c programs and when I go to compile in Ubuntu, such as:

I get the following error:

I’m sure that my permissions for the C files are correct, all files have ‘rwx’ permissions.

Do I have to change the permission of the directory as well?

I’m a complete newb, so apologies.

1 Answer 1

Yes, you have to change the permissions of the directory as well.

This is because if you only have write permissions to the files inside the directory, you can’t just create a new file because you don’t have write permissions for that file (it doesn’t exist, so no permissions to create it).

If you have write permissions for the directory you can create a file inside it because you have write permissions for the directory itself.

To make yourself the owner (terminal way):

Check your user name:

Make yourself the owner of the directory and its contents:

The -R flag stands for recursive, so that directory and all its subfiles and subdirectories will change owner. Remove the -R flag to just change the permissions of the directory itself.

Now you should be able to create files or directories because you’re now the owner of the directory and all its content. If you still can’t, give the owner write permissions to the directory and its content using the following command:

Оцените статью