0

I been trying to compile a c file with

gcc filename.c -o outputfilename

but gcc gives

gcc: error: No such  file or directory<br>
gcc: fatal error: no input files<br>
compilation terminated.

I changed the file permission to 777.

I made sure that my current working directory is the same place as the file. And I also made sure that it is a C source code(text/x-csrc) file type.

  • 2
    That almost certainly means there isn't a file named exactly filename.c in the current directory - perhaps it is named filename.c (with a trailing space) or some such - what does ls -b file* say? The .c file shouldn't need more than read permissions BTW. – steeldriver Nov 2 '16 at 23:00
0

i run this test like you:

 $ gcc main.c -o test2
 $ ./test2
this is your number`s = 13 with string = 13

what files in my folder:

 $ ls -l
-rw-r--r-- 1 dan dan  401 Окт 15 00:54 main.c
-rw-r--r-- 1 dan dan  204 Окт 12 00:01 main.h
-rw-r--r-- 1 dan dan 1984 Окт 15 00:54 main.o
-rwxr-xr-x 1 dan dan 8720 Ноя  3 00:09 test2

gcc look *.c files only in working directory, so to check this:

 $ pwd
/home/dan/git/C/test1

and lets run compile in wrong directory:

 $ cd ..
 $ pwd
/home/dan/git/C
 $ gcc main.c -o test2
gcc: error: main.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
  1. so make sure your work dir is correct, use CD command to change you current dir, more in "man cd"
  2. start to use MAKE utill
  3. you don't need give *.c files exec permission
  • You can make most programs print English messages by prefixing the command with LC_MESSAGES=POSIX, e. g. LC_MESSAGES=POSIX free. Works the same for graphical applications. With super-user privileges you need sudo LC_MESSAGES=POSIX apt ... or gksudo env LC_MESSAGES=POSIX synaptic (for graphical applications). – David Foerster Nov 3 '16 at 9:59

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.