Notepad++, NppExec, CreateProcess() failed with error code 2, Windows 10 - c

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.

Related

Error when using gcc (minGW) to build .exe with same filename?

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!

How to use VC++ compiler in command line(Windows)?

I tried to use VC++ commandline, instead of MinGW compiler for windows system programming. I wrote a simple hello world program and tried to compile it, then i got this error message.
test2.c(1): fatal error C1083:'stdio.h': No such file or directory
I also added "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\Hostx86\x86" directory (where c1.dll lives) to the System Envionment Variable(PATH).
How can I fix this issue? Other tutorials don't give much information about VC++. (A lot of MinGW compiler tutorial out there btw)
You should use visual studio command line if you want to compile or run program with the help of vc++ compiler.
Else all information related to setting environment variables ETC. resides in this MSDN document.

Telling CMake where to find z.lib in Windows

Disclaimer: I'm no software engineer or programmer. I just know enough to get myself in trouble. Please forgive any misused or inaccurate terms.
I'm currently trying to test my HDF5 installation using the in-built Example test scripts. These are organised by CMake and compiled by gcc (MinGW and MinGW-w64). When I go to execute the test script:
ctest -S HDF518_Examples.cmake -C Release -V -O test.log
I'm met with pages and pages of errors, the core of these being:
mingw32-make.exe[2]: *** No rule to make target 'C:/aroot/stage/Library/lib/z.lib', needed by 'bin/h5ex_d_compact.exe'. Stop.
From my hours of trying to fix this on my own, I've been able to work out that z.lib is a library file part of the ZLIB library, ubiquitous these days. I also know that I have at least one copy of this particular file in my Anaconda directory under /Library/lib/.
I have two questions:
1) How can I get CMake or MinGW to recognize where this file is, and hence stop this error? Is there an environment variable I can set, or a config file I can modify?
2) As an aside, where did this path come from? There is no C:/aroot/ directory on my computer. I've also been unable to find any generators for this path in any of the CMake, HDF5, or MinGW files. So why is CMake pointing to this faux-directory?
Any help would be appreciated.
I use ENVIRONMENT PATH in set_tests_properties to specify the dependent external libraries.
set_tests_properties(${Testname} PROPERTIES ENVIRONMENT
PATH=${/your/zlib/location}
WORKING_DIRECTORY "${/your/working/directory}/")

Clang error when trying to open a C file

I recently downloaded vim and I made a simple Hello World program in C. I installed clang after I saw that Gcc had errors on cmd. They both did. I also installed cygwin and tried cmd with both compilers and still nothing.
I keep on getting these errors
1 [main] clang 304 child_info_fork::abort: C:\cygwin\bin\cygLLVM-3.5.dll:
Loaded to different address: parent(0x1A10000) != child(0x1710000) clang:
error: unable to execute command: posix_spawn failed: Resource temporarily
unavailable
I think I have more hope for clang than for gcc
Short Answer: If your Cygwin installation is directly under your C: drive, shutdown Cygwin and try this command in the Windows command prompt:
C:\cygwin\bin\dash.exe -c '/usr/bin/rebaseall -v'
This is a Cygwin fork failure.
As noted in link above, one solution is to do a 'rebase':
Read the 'rebase' package README in /usr/share/doc/rebase/, and follow the instructions there to run 'rebaseall'.
According to the README:
Use the following procedure to rebase your entire system:
1. shutdown all Cygwin processes and services
2. start ash or dash (do not use bash or a terminal emulator like rxvt
or mintty). The easiest way to do this is to use Windows Explorer
and navigate to the top level of your cygwin installation, and
double-click ash.exe or dash.exe in the bin/ directory.
3. execute /bin/rebaseall (in the ash/dash window)
If you get any errors due to DLLs being in-use or read-only, then take the
appropriate action and rerun rebaseall. Otherwise, you run the risk of fork()
failing.

Compiling with C.vim on Windows?

C.Vim works, as evidenced by the commands I've been using, syntax highlighting, and template. But I use \rc and nothing happens. \rr tells me that there is no .exe, and an Everything search tells me that it's not a directory issue.
In all the resources I've read, I don't see anything that says I need to point it to a specific compiler, though I've installed Visual Studio 2010.
How do I get C.vim to compile my code? I'm a relative beginner with Vim and C.
Edit: I've set the Windows Environment Variable to C:/cygwin/bin where I've downloaded and installed the GCC packages, but am still getting the same error.
Edit2: I've downloaded Msys and Mingw as well. I tried setting up Eclipse as well, following the instructions here. Running make from the command line tells me that GNU Make 3.81 is running. Running :make in Vim tells me:
shell returned 2
(1 of 1) : make *** No targets specified and no makefile found
Trying Eclipse, I get another make error:
make: *** No rule to make target `all'; Stop.
Edit3: I got Code::Blocks running, which is what I used to run. (It's been a while since I programmed, and even then I was a beginner.) I didn't really have to configure it at all, though I would still prefer to use Vim, so help is still much appreciated.
Edit4: running make vimFirst (vimFirst.c is my file) compiles! Running the program with :! vimFirst.exe works as expected. Now returning to the original question, how to do it with C.vim? It would be so much more convinient to type \rc and have the program compile and run, which is about 1/10 of the typing of the other method.
Edit4: running make vimFirst (vimFirst.c is my file) compiles! Running the program with :! vimFirst.exe works as expected. Now returning to the original question, ... type \rc and have the program compile and run...
Check your maps for \rc and \rr:
:map \rc
:map \rr
If no mapping exists, you might have no_plugin_maps or something similar set in your vimrc.
I think you'll get what you want if you set them up like this:
nmap \rc :make %<<CR>
nmap \rr :! %<.exe<CR>
If you're really familiar with Visual Studio and want to use nmake to build your code, you should check out the :compiler option. :compiler msvc will setup your makeprg and errorformat for nmake and Visual Studio's compiler.
I'm not sure what make is currently using to build your code, so I don't know what compiler setting you'd want.

Resources