0

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.

Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
Joe
  • 1
  • 1
  • 4
  • My user is already an admin so I should be able to create and write to files right? – Joe Oct 28 '17 at 20:59
  • 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 Oct 28 '17 at 21:04
  • 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 Oct 28 '17 at 21:13
  • 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 Oct 28 '17 at 21:16
  • 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 Oct 28 '17 at 21:21
  • "Ok, so how do I change the permissions of the program instead of the user?" Google would be more of a help there, I only know user and program permissions are distinct on unix. "Also is there a way to run the program without using cygwin?" Not super familiar with Cygwin, but presumably any files/programs it creates will be accessible through windows. Try looking in Cygwin's folder for a root folder. – George Oct 28 '17 at 21:24
  • OK thanks for your help – Joe Oct 28 '17 at 22:36
  • Most likely suspect is an Antivirus interfering, otherwise you are running in a directory with wrong permissions. – matzeri Oct 29 '17 at 09:34

1 Answers1

0

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.

Mr.Someone5352
  • 130
  • 1
  • 9