Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 at 20:29
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.