That post says:
cc -c first.c
This will create an object file, to create an executable file type in:
cc -o first.c
I'm sure that second command was meant to say
cc -o first first.c
that was just mistyped.
Even without that error, the post is misleading, since it doesn't explain why a beginner might ever want the first command (which creates only an object file) vs. the second command that creates an executable.
So it is easy to see how electriceddy misunderstood and thought the second command was for use after the first command rather than instead.
Originally Posted by electriceddy
What would be the correct syntax of the commands if I wanted to compile a program.c in the tmp folder and link it afterwards?
If you want compile and link to be two separate steps:
gcc -c program.c
gcc -o program program.o
The first step creates program.o. The second step uses program.o to create program. It leaves program.o so you have both program and program.o when you're done.
The single step version is
gcc -o program program.c
That compiles (creating the .o file) and links (creating the executable from the .o) then deletes the .o.