Sublime Forum

C Permission denied id returned 1

#1

i got some error, can someone help me?

here the error code :
c:/mingw/bin/…/lib/gcc/mingw32/6.3.0/…/…/…/…/mingw32/bin/ld.exe: cannot open output file test.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
[Finished in 0.3s]

0 Likes

#2

That’s most likely an indication that the program test.exe is currently running. Windows locks files that are in use to stop them from being modified, so if the program is running you can’t compile and link a new copy of it.

Kill the running process (via the Task manager or such) and the problem should go away, if that’s the reason.

Most commonly, this happens to you if you’re trying to run a program that is interactive (i.e. requires the user to type some input). Sublime doesn’t support interactive programs, so what happens is your program runs, it gets to the point where it’s waiting for input, and then it sits there forever because you can’t talk to it.

When you try to compile and run again, you can’t because the program is still running in the background from last time (waiting forever), and because Windows keeps files that are in use locked, the Linker is not able to link a new version of the program when you compile again.

If that’s your issue, I would recommend that you modify the build system to use Terminus instead. This video shows you how to convert a build system to use Terminus.

0 Likes

#3

Test.exe is my C file names

0 Likes

#4

Your source files should have an extension of c, not exe.

0 Likes

#5

I change my file as helloworld.c the error said output file helloworld.exe:Permission denied

0 Likes

#6

It might be clearer what’s going on if you provided the entire build diagnostic and not just the error that you’re seeing; the other parts of the diagnostic output show you what command it was actually trying to execute.

0 Likes