I am a complete novice with Linux. I have Mint on a laptop and have recently been playing around with it.
I wrote a simple C program and saved the file.
Then in the command line I typed
gcc -c myfile
and out popped a file called a.out. I naively (after years of Windows usage) expected a nice .exe file to appear. I have no idea what to do with this a.out file.
Name it with
-oand skip the-c:You should name your sourcefiles with a
.cextension though.The typical way of compiling e.g. two source files into an executable:
You can make this into a single step:
Or, for your case with a single source file:
The
-Wallpart means “enable (almost) all warnings” – this is a habit you should pick up from the start, it’ll save you a lot of headaches debugging weird problems later.The
a.outname is a leftover from older unixes where it was an executable format. Linkers still name filesa.outby default, event though they tend to produceELFand nota.outformat executables now.