When I try to compile helloWorld.c with gcc (by MinGW) via notepad++'s run feature I get the error:
cannot open output file helloWorld.exe: Permission denied
The problem only occurs when I run the compiler via notepad++'s run feature, so I get no errors when I just compile it manually via cmd.
As some others have answered on similar questions, I have tried looking in process explorer and helloWorld.exe is not running.
.
Additional details about how I run it in notepad++
I use a batch script compile.bat
gcc -o %1 %2
%1
PAUSE
and run it in notepad++ with the command
"...\compile.bat" $(NAME_PART) $(FILE_NAME)
What could be causing this error? Help would be deeply appreciated.
EDIT: Turns out it was a problem with notepad++ that it didn't display that it was working in it's own directory. Also what caused a problem when I had tried to put the directory in the batch file was that it couldn't handle scandinavian letters.
I suspect that notepad is trying to create the output file in it's own directory (ie somewhere in c:\program files\notepad++" that you don't have write permission to.
Is there a "working directory" setting in notepad++'s run command?
Related
Hi I'm new to C Programming and Notepad++. I can't seem to find the solution to this problem when I was configuring C compiler for Windows 10.
NPP_SAVE: C:\Program Files\Notepad++\change.log
CD: C:\Program Files\Notepad++
Current directory: C:\Program Files\Notepad++
gcc -o "change.exe" "C:\Program Files\Notepad++\change.log"
Process started (PID=16420) >>>
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: cannot open output file change.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
<<< Process finished (PID=16420). (Exit code 1)
"change.exe"
; about to start a child process: ""change.exe""
CreateProcess() failed with error code 2:
The system cannot find the file specified.
================ READY ================
The NppExec script I have taken from https://www.youtube.com/watch?v=_dGyVkPkBRI&t=88s
npp_save
cd "$(CURRENT_DIRECTORY)"
gcc-o "$(NAME_PART).exe" "$(FULL_CURRENT_PATH)"
"$(NAME_PART).exe"
Please help advice, thank you.
I'm afraid this cannot work. As far as I see, you are trying to compile the file change.log, which is almost certainly not a C module (or anything else gcc might understand.
Please re-check the FULL_CURRENT_PATH variable in the script you posted. I think there is a misunderstanding in the youtube clip (which I didn't watch), or in the way you tried to reproduce it.
Additionally, such scripts are not an ideal solution to automate the program build and execution any more. You should check out better alternatives such as an IDE (Eclipse, Netbeans, Visual Studio or whatever you prefer...), or learn to write yourself a Makefile (check out the GNU Make tool), which is much more powerful than a cmd script.
PS: Notepad++ is a nice editor, but it isn't an IDE. As soon as you are programming software that consists of several modules and/or header files, you want to surf through these efficiently in order to avoid mistakes.
I've been trying to build another .exe file with the same name in minGW, but everytime I run the command: gcc file.c -o file.exe I run into the problem of:
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe:
cannot open output file main.exe: Permission denied
collect2.exe: error: ld returned 1 exit status
But, if I run the same command with gcc file.c -o file2.exe the command executes fine, and I can compile my C code. Is there any way to build .exe files with the same name?
My C code is a simple "hello world":
#include<stdio.h>
void main(){
printf("hello world");
}
Thank you!
Updates:
checked task manager, but the .exe is not running in the background.
I have writing permission to the folder
My antivirus doesn't seem to be the problem
I can edit and delete the file.exe "by hand". I used command line to rename it to file1.exe, but when I tried to rename it back to file.exe I got an "access denied". Even though I am running command line as an admin.
file.exe is just a generic name to ask this question instead of giving the
name of my project
Looking at this question: Command prompt access is denied
I saw a comment that helped:
Noting C:> in your question, your Windows root drive is usually write protected, you may find that simply changing directory to somewhere without that protection may also help. – Compo
And indeed, having my file in the root drive was the problem. Sorry I didn't provide enough information for those who helped. But thank you so much for the help!
i'm using lld-link to create a .exe file from a obj file but this happen:
I already searched for this error, the common answer was that a.exe was executed and that I have to close it , but I already search for it in the process explorer and there is no a.exe running. I also read that my anti-malware could be the problem so I turned it off but that didn't work as well.
You're trying to write a.exe into C:\Program Files\LLVM\bin. Either cd to your code directory before linking, or specify an absolute path for a.exe to be saved to in the -out:a.exe part of the command.
I am having trouble while using the codeblocks-16.01mingw-setup.exe - installed in a file whose path does not contain spaces - when trying to compile at a comand prompt. A beginner's guide recommended using the following line in command prompt:
gcc cards.c -o cards
for the source file named cards.c (on my desktop). This gives the error
'gcc' is not recognised as an internal or external command, operable program or batch file.
When trying to figure this out, I have found out that you can drag and drop files in your command prompt and it specifies their path. Doing this with the gcc.exe taken from F:\Programare\Codeblocks\MinGW\bin\gcc.exe and adding the c source file as C:\Users\dream\Desktop\cards.c gives the error
as.exe - System error: The program can't start because libintl-8.dll is missing from your computer. Try reinstalling the program to fix this problem.
I've reinstated my Codeblocks to no avail. I've also tried matching the paths of the compiler with the source file, bringing the source code where the compiler was, again to no avail.
Please help me understand the issue. I must say that the file named libintl-8.dll is right there where gcc.exe is, trying to add it in the command prompt gives some syntax error.
gcc is trying to find that dll file in the working directory, so you need to cd into that directory cd /d F:\Programare\Codeblocks\MinGW\bin.
Dynamic-Link Library Search Order (Windows)
The directory specified by lpFileName.
The system directory. Use the GetSystemDirectory function to get the path of this directory.
The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
The current directory.
The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.
You have to add F:\Programare\Codeblocks\MinGW\bin\ to your users or systems PATH environment variable.
Once you have done this you can simply type
gcc cards.c -o cards
So i'm trying to compile my helloworld.c file on my desktop using cl under "Administer: Developer Command Prompt for VS2015".
I figure it's environment var problem by doing some Google, and follow the link below to set it. (https://msdn.microsoft.com/en-us/library/1700bbwd.aspx)
But after i found and ran the VSVARS32 file under
"Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools",
i still can't use my cl command, showing that
"'cl' is not recognized as an internal or external command, operable program or batch file."
Please help me, any suggestions would be appreciated