I think I’ve probably spent… more than an hour? but less than three hours? My entire life? on a Windows machine, so I’m the most qualified person ever to explain how to get started developing Emacs on Windows.
Because people who’ve used Windows before don’t really know what other people don’t know. It’s about the unknown unknowns.
So here’s a guide to get this working anyway, if you’re a Linux-ey person, and for some inexplicable reason you want to build the development version of Emacs on Windows.
1) Install Windows in a VM. Download the ISO from here. Then open virt-manager on your GNU/Linux machine, create a new machine, and point it at the ISO. You’ll be faced with a whole bunch of questions from Windows when installing, but answer “no” to as many as possible. Less surveillance is better.
2) After it’s up and running, search for “powershell” in the search field at the bottom of the screen. Start the “for administrators” version.
3) Type this:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Yes, those tildes and the numbers and all. And then:
Start-Service sshd Set-Service -Name sshd -StartupType Automatic ssh localhost
The latter should give you a login, so just try that to see whether it works.
4) From your GNU/Linux machine, say
scp ~/.ssh/authorized_keys windblows:.ssh/
This will later enable you to ssh to the machine without passwords, but first we have to do more confing, so we might as well just start installing the Linux-ey prerequisites already, because that makes things easier.
5) Install Cygwin by clicking on the “setup-x64_64.exe” link. It’ll ask you more questions, but just answer yes to everything.
6) Done! You don’t need to do anything more on the console, so get back to the couch and do the rest via ssh from a GNU/Linux machine, like a proper human being.
You can copy and paste the rest of this into your ssh session:
C:\cygwin64\bin\bash -l sed -i -E 's/^Match Group administrators|AuthorizedKeysFile __PROGRAMDATA__/#&/' /cygdrive/c/ProgramData/ssh/sshd_config powershell -command "restart-service sshd" curl -O https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg install apt-cyg /bin sed -i 's/lynx -source/curl/' /bin/apt-cyg apt-cyg install wget apt-cyg install gcc-core git automake autoconf libgnutls30 make gnutls libncurses-devel gnutls-devel libjpeg-devel libpng-devel libharfbuzz-devel libXpm-noX-devel libgif-devel libxml2-devel libjansson-devel libdbus1-devel librsvg2-devel libtiff-devel libXpm-devel git clone https://git.savannah.gnu.org/git/emacs.git cd emacs ./autogen.sh ./configure --with-native-image-api --with-w32 make -j8 ./src/emacs
Presto! This should now be displaying in the VM, if you run over to it and have a look:
But you’d normally say
when working remotely from the sofa, of course.
Additional tweaks: Windows only uses one CPU by default (?), and qemu/virt-manager will tell the Windows client that it has many CPUs. To make it say that it has a lot of cores instead, say:
# virsh edit win10
Find the bit that says:
<cpu mode='host-model' check='partial'> and edit that into:<cpu mode='host-model' check='partial'> <topology sockets='1' dies='1' cores='8' threads='2'/> </cpu>
Or however many cores/cpus you have. This will make building Emacs a lot quicker.
(Tips for improving the installation recipe are welcome, of course.)