Friday, 10 June 2016

How to use GCC and make


GCC is the main compiler for C.

To compile a C file.


gcc -o hello hello.c


Running the executable

./hello



Makefiles is used for building the whole project. This is an example file.


all: hello

hello: hello.o
     gcc -o hello hello.o

hello.o: hello.c
     gcc -c hello.c
    
clean:
     rm hello.o hello


Use this to build everything into a executable.

make



Use this to clean the project.

make clean




No comments:

Post a Comment