0
votes

I'm using cygwin to compile and windows 10. My question is whenever I try to compile I get an error saying:

/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot open output file a.exe: Permission denied collect2: error: ld returned 1 exit status

It started when I compiled a program that creates a file and then writes to that file, but I don't know why my computer doesn't allow me to create a file in a program. I have no idea how to fix it so I can write to file. Any help is appreciated.

1
My user is already an admin so I should be able to create and write to files right?Joe
Sorry didn't fully read the question, my bad. You could run your program (not cygwin) as admin or change the permission to allow everyone to write to the directory your program is trying to write to.George
Ok but doesn't my user already have permission since it is an admin or do I need to set special permissions to that folder?Joe
Your user might, doesn't mean the program does. You can set the dir so anything can write to it, or give the program the correct permission level. You could also try running Cygwin as admin through windows as the first answer suggests, though tbh I don't see why that would have any effect as it shouldn't change the permission level of programs run through Cygwin.George
Ok, so how do I change the permissions of the program instead of the user? Also is there a way to run the program without using cygwin?Joe

1 Answers

0
votes

You probably need to run Cygwin as an administrator.

EDIT

I found this:

Root user/sudo equivalent in Cygwin?

Try the accepted answer. It should work.