I use Emacs 25.1 on my Windows XP laptop both as a command-line app (on ConEmu terminal emulator with MSYS bash as the shell) and as the GUI Emacs. I mainly use Emacs to test and compile programs, so I frequently use Mono C# compiler (gmcs) and GCC. The path of gmcs is defined inside the Windows environment variable Path, so when I use gmcs in GUI Emacs, it works.
But the path of GCC (/c/MinGW/bin) is defined inside ~/.bashrc and if I try to use GCC in GUI Emacs, it doesn't work.
If I start emacs -nw from within ConEmu terminal and try to compile a C code using
M-x compile & gcc my-c-code.c -o my-c-code.exe there's no problem: Emacs recognizes the gcc command and does the compilation.
When I try to do the same thing in GUI Emacs it says:
gcc my-c-code.c -o my-c-code.exe
/usr/bin/bash: gcc: command not found
To introduce the GCC's path into Emacs's exec-path I've added these into .emacs file:
(setq exec-path (append exec-path '("C:/MinGW/bin")))
(setenv "PATH" (concat "C:/MinGW/bin" (getenv "PATH")))
(setq shell-file-name "C:/msys32/usr/bin/bash.exe")
but none of them helped. The last line helped only if I open a shell within GUI Emacs, but not at the M-x compile stage.
How can I define the path of GCC inside the .emacs file? Note that I might add the path of GCC in the Windows env variable Path, but I don't want to solve it that way, I'd like to solve it the Emacs way. Thank you!