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.

  • 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

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.

| 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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