2

So, Windows System on Linux seems to be an inovative light-weight substitute for a virtual machine, especially when it comes to learning Linux. Nevertheless, for me WSL seems to have a little more complicated organization from a VM when it comes to file management. For example, in WSL the data are stored in

C:\Users\<username>\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\

as shown here. Of course my first try to install GCC was to type in:

sudo apt install gcc

,but after typing

gcc --version

the output was :

Command 'gcc' not found, but can be installed with:

sudo apt install gcc

After that, I tried installing GCC using the following commands as shown here :

$ sudo apt-get update && sudo apt-get upgrade -y
$ sudo apt autoremove -y
$ sudo apt-get install gcc -y

but I end up getting the same output. On the other hand, I already had installed TDM GCC on Windows and used sudo in VM to install it also there (successfully:). Like a lot of people, I want to substitute the use of my virtual machine with WSL in order to be able to develop in C without overloading my RAM my questions are :

  • Can you count out for me how many times have I downloaded GCC files?
  • Why the folder that I was supposed to be downloading the gcc files in is shown to be empty?
  • Where are the downloaded files being stored?
  • How can get gcc fired up?
  • Is there any way to use the gcc I had on Windows to compile C using the WSL terminal?

    I think these questions come from the fact that I cannot understand how WSL file system interacts with Windows. They are a bit more generic on purpose because I want you to have a lot of "answering" freedom. Please help me out of this one! I don't want to be forced to use a virtual machine and run out of RAM almost every time!
  • qiu
    • 121
    • 7
    • 1
      Assuming you haven't messed with paths, it should "just work". You shouldn't have to mess with WSL1 files from Windows, that can cause issues. That being said, this isn't a programming question, and would belong on a different SE. – Thomas Jager Feb 24 '21 at 15:02
    • If what you're trying to understand is how WSL interacts with Windows then this question is off topic on SO, but it would be on-topic on [Super User SE](https://superuser.com/). – John Bollinger Feb 24 '21 at 15:03
    • In my experience, however, inside a WSL container, using the installed distro's standard software management tools works as expected (that is, it manages the software installed *in the container*). The container and host are logically separate machines, so, among other things, one should not see or have direct access to the software installed within the other. – John Bollinger Feb 24 '21 at 15:08
    • You should be aware that WSL has some limitations that hit you when you don't expect it. – Eugene Sh. Feb 24 '21 at 15:22
    • For example: https://stackoverflow.com/questions/64053890/socket-c-address-family-not-supported-by-protocol – Eugene Sh. Feb 24 '21 at 15:29
    • Your problem is other than what you described. Something is different from what you told us. We have no idea what it is. – Joshua Feb 24 '21 at 15:31
    • @JohnBollinger Ok,I agree to assume that using the "Windows" gcc is out of the question and I have to reinstall it into WSL . Why can I not see any changes (using ls) in the directory that I just downloaded gcc files ? – qiu Feb 24 '21 at 15:32
    • I did not want to make my question too personalized because it wouldn't have any difference from asking for a pull requet on GitHub. Also there isn't much code to post as it is supposed to be an installation problem. It is not an error since it doesn't return any error code. – qiu Feb 24 '21 at 15:37
    • @qiu, the `apt` and `apt-get` commands listed in the question appear to be appropriate for installing GCC, but in general, there is no reason to expect that they would modify the working directory from which you run them. If successful, they will install the software into an appropriate central location, and they will update a central database of installed packages. But it is now clear that this is a question about system administration, not programming, so again, it is off-topic for SO. – John Bollinger Feb 24 '21 at 15:46
    • @John Bollinger Ok so if that is the case I will repost it on SE and send you the link over! – qiu Feb 24 '21 at 15:57
    • You should also let people know whether you are on WSL1 or WSL2. Major difference between the versions. I suspect you are on WSL2. – fpmurphy Feb 24 '21 at 16:24
    • @fpmurphy Yes you are correct, it is WSL2. Do not hasitate to ask for more info as long as you are willing to help. – qiu Feb 24 '21 at 16:39
    • @qiu I just installed `gcc` and it worked for me as `/usr/bin/gcc`. Installed version: `gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0` – fpmurphy Feb 24 '21 at 17:01
    • @ fpmurphy Thank you SO much what I was not doing all the previous times is that I wasn't installing it at the bin directory, which makes perfect sense to me after your comment! Thank you all so much for your interest! Especially fpmurphy who had the kindness to read both my question and the comments (because he was the last commentator). @fpmurphy You could post your comment as an answer if you want, I will accept it. – qiu Feb 24 '21 at 19:25

    0 Answers0