Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiler gcc:error; no such file or directory [closed]

Tags:

c

gcc

I am extremely new to programming and I am having problems with the basic starting program of, 'hello, world'.

I have downloaded MinGW and I believe I set it up correctly with the command promt by entering: setx PATH "%PATH%;C:\MinGW\bin"

Then I created this code following a guide while using Notepad++

#include <stdio.h>

int main(void)
{
  puts("Hello, world!");
  return 0;
}

saving it under c:/code/c/hello.c

When I try to compile it or run it under: gcc -o hello hello.c, I get this error

gcc: error: hello.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.

And I am not sure how to fix this. I have tried looking around, but I cant find any answers or I just don't understand them.

like image 910
sarakota Avatar asked Oct 18 '22 12:10

sarakota


1 Answers

gcc: error: hello.c: No such file or directory gcc: fatal error: no input files compilation terminated.

Means that gcc is unable to find your hello.c source file. You should either cd to the source folder:

c:
cd c:\code\c\
gcc -o hello.exe hello.c

Or use a full path to the source in the command line:

gcc -o c:\code\c\hello.exe c:\code\c\hello.c
like image 138
Ari0nhh Avatar answered Oct 21 '22 01:10

Ari0nhh