Compile and Run C Programs in Linux using GCC Compiler

arp14 C Programming Tags: , , , , 0
Compile and Run C Programs in Linux using GCC Compiler

Compile your C program

Open up terminal and enter the following command

gcc hello.c -o hello.bin -lm

The included libraries must be linked in when building the executable. How to do this varies by environment, but in Linux/Unix, just add -lm to the command.

Run the compiled program

Please note the dot followed by forward slash before the output file name.

./hello.bin

Leave a Reply

Note: Your email address will not be published. Required fields are marked *