1

I have recently gotten into programming this is a small C code I started on.

I am using Ubuntu 13.10.

int main(int argc, char *argv[])

{

    puts("Hello world.");

    return 0;
}

Whenever I try to compile it using

gcc exl.c -o exl1
cc exl.c -o exl1

or anything like that i just keep getting

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

I have no Idea what to do any help would be greatly appreciated.

P.S. I have already done

sudo apt-get install build-essential
sudo apt-get update build-essential
sudo apt-get upgrade build-essential
3
  • 3
    Well, the error is about a non-existing exl.c file. Are you sure you saved the code to the contents of a file with that exact name in the current working directory or changing to the full path? This is really a 'simple' file location issue, rather than a compilation error.
    – gertvdijk
    Feb 17, 2014 at 15:55
  • Do let us know when you compile it successfully. Feb 17, 2014 at 17:08
  • I fixed it, all it required was for me to make a directory for the file and run the terminal in the file, thanks to everyone for the help.
    – Sornarok
    Feb 17, 2014 at 23:02

2 Answers 2

2

You need to run gcc in a directory where your C code is stored, so first use:

cd /home/your-user-name/path-to-program-dir

and then run gcc. To make sure that you have to C file in same directory use

ls *.c

which will show you all the C files in current directory. If you are not sure in which directory your code is stored then you may want to use

find
1
  • Thanks, I recently found the issue was that I wasn't running the terminal in the directory and I didn't have a directory made. Thank you again for helping fix this situation.
    – Sornarok
    Feb 17, 2014 at 23:01
-1

If you use gedit then after saving c file use ctrl-M. It will open terminal in your program directory.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .