GCC Fatal Error

21,446

Solution 1

Desktop is not located at /Desktop rather it is located at ~/Desktop. Thus execute these commands.

  1. cd ~/Desktop (for changing directory to Desktop)
  2. gcc hello.c -o hello (for compiling C program)
  3. Then execute your application by ./hello , if it shows any error change its permissions with chmod +x hello

Solution 2

Then I typed within the terminal: cd /Desktop

/Desktop is not the path to your desktop. /Desktop is the path to a directory "Desktop" in / (your root directory). /home/<username>/Desktop or, shortened, ~/Desktop is the path to your desktop.

So first change your terminal's working directory to your desktop's path:

cd ~/Desktop

Then compile the file again:

gcc hello.c -o hello
Share:
21,446

Related videos on Youtube

guntbert
Author by

guntbert

Updated on September 18, 2022

Comments

  • guntbert
    guntbert over 1 year

    everyone

    Here's my problem; So, I'm new to Ubuntu and programming and I just wanted to start with C. I created the classic "hello.c" file

    #include <stdio.h>   
    main ()
    {
        printf("Hello World!");
    }
    

    Then I typed within the terminal:

    cd /Desktop
    

    Because the file is located in Desktop

    And then I typed

    gcc hello.c -o hello
    

    But here come the troubles, it suddenly appeared a problem that says:

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

    So, how can I fix that?

    • j0h
      j0h about 9 years
      I seem to recall gcc used to just say "no input files" That seems less confusing.
  • Thomas Ward
    Thomas Ward about 9 years
    gcc gives it +x by default, I thought... at least in 14.04 and later.