gcc: fatal error: no input files compilation terminated

I'm new to linux environment. I created a file s1.c in a folder named 'program' which is present in desktop. When I try to compile my code using "/program gcc s1.c " it's showing "gcc: error: s1.c: No such file or directory gcc: fatal error: no input files compilation terminated." What may be the problem

1

2 Answers

It seems like you are not in the same directory or you are not firing the command for program folder where s1.c file is located.

Make sure that you are running gcc s1.c while you are in program directory or you can try gcc program/s1.c if you are not in program directory.

You can refer this attached image for more info.

enter image description here

0
$ cd ~/Desktop/program
$ gcc s1.c -o s1
$ ./s1
  • The first command changes in to the directory ~/Desktop/program.
  • The second compiles your C program s1.c1, the resulting executable is called s1.
  • The third command executes the executable called s1.
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like