title: Installing g++ on windows subsystem for linux
body: <p>A while back I activated Windows Subsystem for Linux on my machine but didn't use it much. Now I have an idea what I could use it for and that is why I'm trying to install gcc/++ 7 on my WSL and keep running into problems.</p>
  
  <p>My idea was to <a href="https://ftpmirror.gnu.org/gcc/gcc-7.3.0" rel="noreferrer">download</a> it and compile it by hand following <a href="https://solarianprogrammer.com/2017/05/04/building-gcc-wsl-windows-subsystem-linux/" rel="noreferrer">this guide</a> with:</p>
  
  <pre><code>../gcc/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=${HOME}/software/gcc-7.3.0/installDir --enable-checking=release --enable-languages=c,c++,fortran --disable-multilib
  </code></pre>
  
  <p>This led to the following error:</p>
  
  <pre><code>checking build system type... x86_64-pc-linux-gnu
  checking host system type... x86_64-pc-linux-gnu
  checking target system type... x86_64-pc-linux-gnu
  checking LIBRARY_PATH variable... ok
  checking GCC_EXEC_PREFIX variable... ok
  checking whether to place generated files in the source directory... no
  checking whether a default linker was specified... no
  checking whether a default assembler was specified... no
  checking for x86_64-linux-gnu-gcc... no
  checking for gcc... no
  checking for x86_64-linux-gnu-cc... no
  checking for cc... no
  checking for x86_64-linux-gnu-cl.exe... no
  checking for cl.exe... no
  configure: error: in `$HOME/software/gcc-7.3.0/build':
  configure: error: no acceptable C compiler found in $PATH
  See `config.log' for more details.
  </code></pre>
  
  <p>Apparently, there was no(?) gcc installed at all. At least <code>gcc</code> and <code>cc</code> yielded "command not found". So my next step was installing gcc via:</p>
  
  <pre><code>sudo apt install gcc
  </code></pre>
  
  <p>This worked: </p>
  
  <pre><code>$ gcc --version
  gcc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4 
  Copyright (C) 2013 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  </code></pre>
  
  <p>However when trying the configure command from above I got:</p>
  
  <pre><code>checking build system type... x86_64-pc-linux-gnu
  checking host system type... x86_64-pc-linux-gnu
  checking target system type... x86_64-pc-linux-gnu 
  checking LIBRARY_PATH variable... ok
  checking GCC_EXEC_PREFIX variable... ok
  checking whether to place generated files in the source directory... no
  checking whether a default linker was specified... no
  checking whether a default assembler was specified... no
  checking for x86_64-linux-gnu-gcc... x86_64-linux-gnu-gcc
  checking for C compiler default output file name...
  configure: error: in `/home/seriously-ubuntu/software/gcc-7.3.0/build':
  configure: error: C compiler cannot create executables
  see `config.log' for more details.
  </code></pre>
  
  <p>So I tried to compile a simple c program by hand:</p>
  
  <pre><code>int main() {
      return 42;
  }
  </code></pre>
  
  <p>Which hints that something seems to be seriously broken</p>
  
  <pre><code>$ gcc foo.c
  /usr/bin/ld: cannot find crt1.o: No such file or directory
  /usr/bin/ld: cannot find crti.o: No such file or directory
  /usr/bin/ld: cannot find -lc
  /usr/bin/ld: cannot find crtn.o: No such file or directory
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>Any Ideas where I can even start to repair this? I wouldn't even mind reseting the whole WSL if this helps :/</p>
  
  <pre><code>lsb_release -a
  No LSB modules are available.
  Distributor ID: Ubuntu
  Description:    Ubuntu 16.04.3 LTS
  Release:        16.04
  Codename:       xenial
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Before all of this I tried installing gcc7 / g++/ via apt without success:</p>
  
  <pre><code>$ sudo add-apt-repository ppa:jonathonf/gcc-7.1
  $ sudo apt-get update
  $ sudo apt-get install gcc-7 g++-7
  Reading package lists... Done
  Building dependency tree
  Reading state information... Done
  Some packages could not be installed. This may mean that you have
  requested an impossible situation or if you are using the unstable
  distribution that some required packages have not yet been created
  or been moved out of Incoming.
  The following information may help to resolve the situation:
  
  The following packages have unmet dependencies:
  g++-7 : Depends: libstdc++-7-dev (= 7.1.0-10ubuntu1~16.04.york0) but it is not going to be installed
          Depends: libisl15 (&gt;= 0.15) but it is not installable 
  gcc-7 : Depends: cpp-7 (= 7.1.0-10ubuntu1~16.04.york0) but it is not going to be installed
          Depends: binutils (&gt;= 2.26.1) but 2.24-5ubuntu14.2 is to be installed
          Depends: libisl15 (&gt;= 0.15) but it is not installable
          Recommends: libc6-dev (&gt;= 2.13-0ubuntu6) but it is not going to be installed
  E: Unable to correct problems, you have held broken packages
  </code></pre>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Sadly none of the suggested ways helped and I ended up nuking the WSL. Apparently, something more severe was broken.</p>