I’ve been using Emacs for quite some time for basic text editing but as of today I am attempting to use it for c++ compilation. I have looked for the past few hours about how to go about this but I keep hitting roadblocks in their techniques (I think some of this is having to do with the tutorials being outdated).
Basically, all I want to do is be able to compile C++ programs that I write in Emacs through the ‘M-x compile’ command.
So far I have installed Cygwin and downloaded the packages for gcc. I have attempted some other solutions presented by tutorials online but they didn’t pan out.
Thank you.
The
M-x compilecommand calls out to a shell (e.g. linuxbash, windowscmd.exe, etc) to run themakecommand. On windows I think emacs defaults to thecmd.exeshell (through a specialC:/Program Files/Emacs/emacs/bin/cmdproxy.exeexecutable).If you want your
M-x compileto use a different shell (probably cygwinbashin your case) then you need to tell emacs through changingshell-file-namevariable or using theSHELLenvironment variable. You will also need to make sure that the cygwinmakeis found by changingexec-pathvariable (or usingPATHenvironment variable).To do this:
And you could also look at setup-cygwin.el to set this up and some other things for cygwin.