GCC compiler errors with "No such file or directory"
47,238
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.
Related videos on Youtube
Author by
MoonTom
Updated on September 18, 2022Comments
-
MoonTom almost 2 years
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.
-
עוז סולומון over 10 yearsKeep 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, whereasgcc sort.c -o sort
will.
-
-
MoonTom over 11 yearsthanks! 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? -
Colin Ian King over 11 yearsWell, 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