c:/mingw/bin/…/lib/gcc/mingw32/5.3.0/…/…/…/…/mingw32/bin/ld.exe: cannot open output file C:\Users\Servidor\Desktop\Proyect C++/Ejemplo C++ variables.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
[Finished in 0.1s with exit code 1]
[shell_cmd: g++ “C:\Users\Servidor\Desktop\Proyect C++\Ejemplo C++ variables.cpp” -o “C:\Users\Servidor\Desktop\Proyect C++/Ejemplo C++ variables” && “C:\Users\Servidor\Desktop\Proyect C++/Ejemplo C++ variables”]
[dir: C:\Users\Servidor\Desktop\Proyect C++]
[path: C:\MinGW\bin;C:\MinGW\bin;]
How to fix this error when copying the F7 key
The linker telling you it doesn’t have permission to open the file it’s about to create is an indication that the program is still running at the time you’re trying to recompile and re-link it.
You should be able to clear the problem by exiting your program before you recompile it.
Hi OdatNurd
how would you change its permission setting so it can recompile itself.
thank you.
In this case you can’t; you’re not allowed to modify the program because it’s still running. There isn’t a permission for that because the operating system itself has locked the file to stop you from deleting it while it’s still executing. Technically speaking the reason for that revolves around the idea that Windows may discard some of the loaded program from memory if it needs to, so it needs the original program file that it loaded from to be available to be able to load it back in again.
For this reason the only way to stop this error from happening is to terminate the program that’s running before you try to build it again, as I mentioned above.
If the program is running outside of Sublime in an external window of some sort, then go there and quit the application and you’ll be able to build again.
If there is no external window, then likely it’s running because you used Sublime to start it. An example of that is using a build system that first builds and then runs the program like the build in C++ Single File build system. If that’s the case, you have two options:
-
If you know that the program is still running BEFORE you try to build it again, select
Tools > Cancel Buildfrom the menu to stop the running program, which in most cases is going to do what you want and you can then proceed to build again. -
If you see this message, it’s already too late; the old build system that started the command running is now in the background waiting for your program to finish. In this case
Tools > Cancel Buildis going to be grayed out and the only thing you can do is use the windows Task Manager to find and stop the program so you can build it again.
One of the most common reasons to see this error happen is because you’re using Sublime to build and run a program that requests input from the user before proceeding. When you do that, your program is going to hang forever waiting for the input because you can’t interact with a running program from within Sublime.
You then try to build the program again, which severs the connection that Sublime has to the process that’s still waiting in the background, and now you can’t build because the program is still running waiting for input it’s never going to get.