3

My Ubuntu version is 12.04 LTS. I have written some C programs. But there is a compiler-problem. I've googled and found that I need build-essential. So I download and installed it.

After installation, it worked well. But after maybe 3 hours, the problem happened again.

When I write:

gcc -o -std=c99 sort sort.c

The compiler complains:

gcc: error: sort: No such file or directory.

I have no idea now.

1
  • Keep in mind, the order of the files and optional args is important. Like the answer below says, gcc -o sort sort.c will not link, whereas gcc sort.c -o sort will.
    – Piper
    Feb 1, 2014 at 20:29

1 Answer 1

4

The following will fix your problem:

gcc -std=c99 sort.c -o sort

Your command was telling gcc to compile a file called sort, which didn't exist, hence the error message. The -o flag needs to be followed by the output name, but your line it was followed by -std=c99 which is not correct.

2
  • thanks! so it works. I've just wrote everything like examples. Now i know why. but still i want to know: is there someway to make gcc -o -std=c99 sort sort.c working?
    – MoonTom
    Nov 16, 2012 at 0:34
  • Well, as said before, the -o option needs to specify the name of the output, so having the -std=c99 option immediately after -o is just not going to work. How about gcc -o sort -std=c99 sort.c Nov 16, 2012 at 0:48

You must log in to answer this question.

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