GCC Fatal error output: no such file

Ask Ubuntu Asked by user2483829 on October 16, 2020

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.

One Answer

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

and lets run compile in wrong directory:

 $ cd ..
 $ pwd
 $ 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

Answered by Zulljon on October 16, 2020

Add your own answers!

Related Questions

Teamviewer 11 won’t work on Ubuntu 20 Login Screen

1  Asked on November 23, 2021 by nikola-tepavac


Network interfaces not enabled at boot

1  Asked on November 23, 2021 by alexander-trauzzi


Clear swap on every shutdown

0  Asked on November 23, 2021 by corrupt_disk1


How to setup my Scarlett 2i2?

1  Asked on November 21, 2021 by bebel


GRUB not responding to keyboard

17  Asked on November 21, 2021 by brianw


Arrow Keys not working in GRUB

9  Asked on November 21, 2021 by user218937


Abort class-pclzip.php : Missing zlib extensions

2  Asked on November 21, 2021 by zkvvoob


Unattended-Upgrade::Automatic-Reboot default value

3  Asked on November 21, 2021 by stringer


Usb wifi dropped out / rtl8192eu-linux-driver on Ubuntu 16.04

1  Asked on November 21, 2021 by steve-mcgarry


Install mercusys wifi adapter in Ubuntu 20.04

1  Asked on November 21, 2021 by frostfox


Has ‘Ubuntu Software’ been renamed to ‘Snap Store’?

5  Asked on November 21, 2021 by mekacher-anis


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP