0

I have installed Ubuntu subsystem in Windows 10 and I also installed gcc. I wrote a simple Hello world C program and saved it in documents. When I try to compile this program I get this answer:

Tony316@DESKTOP-2ONG1CO:~$ gcc Hello.c -o Hello
gcc: error: Hello.c: No such file or directory
gcc: fatal error: no input files compilation terminated.

I think I have to put my Hello World program in the correct file for gcc to find it, but I don't know how to compile it.

I know this question may have been asked before from users that run only ubuntu in their PC, but I am running it on Windows 10 and I couldn't find anything relevant

Zanna
  • 70,465
Tony316
  • 11
  • "saved it in documents."? But you're telling gcc that it's in the current directory. What does gcc Documents/Hello.c -o Hello produce. – waltinator Mar 23 '18 at 14:13
  • I run it and this is what comes out: Tony316@DESKTOP-2ONG1CO:~$ gcc Documents/Hello.c -o Hello gcc: error: Documents/Hello.c: No such file or directory gcc: fatal error: no input files compilation terminated. – Tony316 Mar 23 '18 at 14:23

1 Answers1

3

As I understand it (this is a result of some quick research), the Bash environment in Windows has two separate "home" directories: one containing your Windows files and the other containing files such as .bashrc and other traditional home directory files found in Linux. To navigate to your Windows Document folder type: cd /mnt/c/Users/yourusername/Documents/. From there, compile your program using gcc with gcc Hello.c -o Hello.