GCC Compilation - learnclang/1-helloworld GitHub Wiki

In your terminal, type the following.

$ gcc hello.c

By default, gcc will store the result in a file in the current directory as a.out. We can run this file like this.

$ ./a.out
Hello, World!

Hello, World!

That's it! We did it! The resulting a.out is a binary executable that you could run on any other machine under similar conditions as yours - that is, not Windows, but possibly other distributions Linux and certainly other installations of Ubuntu 12.04.

For more information about where this binary will run, see here:

Extra Credit

You can pass a flag to gcc to make it output to a custom file.

$ gcc hello.c -o hello

This will produce the file hello right next to the source file.

Return Home