Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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. – piperchester Feb 1 '14 at 20:29
up vote 3 down vote accepted

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.

share|improve this answer
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 '12 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 – Colin Ian King Nov 16 '12 at 0:48
Now i konw waht to do. thank you so much. – MoonTom Nov 16 '12 at 0:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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