opklaunch.blogg.se

Create makefile for c program
Create makefile for c program







create makefile for c program

$ cc -o getinfo main.c getname.c getaccno.c header.h

create makefile for c program

Using the cc command, you would typically do the compilation as shown below.

create makefile for c program

Create the Makefile to Compile More than One Fileįor the multiple file compilation, let us use three files - getname.c, getaccno.c and main.c.īased on these three *.c files, let us create an executable called “getinto”. If the make filename is different than any of these two, you should specify that to the make command using -f option as shown below.įor those who are new to C, read C Hello World Program article. Please ensure that both makefile and the source code are present in the same directory, otherwise specify the respective path of source files in makefile.īy default, make command expects the make filename to be either Makefile or makefile. Since makefile contains only one target “helloworld”, you can also call make command without any argument as shown above.”make”. Create a makefile as shown below.Įxecute make to create the helloworld executable as shown below. While you don’t need to use make for compiling single a program, the following example will give you an idea on how to use make. Using cc command, typically you would compile it as shown below. Let us assume that you have the sample C program file called helloworld.c. Create the Makefile for a Simple Compilation In this article, let us review how to use make command.ġ. For compiling multiple C programs, Make utility is very helpful.Īlso, C programmers and sysadmins will find it helpful to automate the compilation related tasks using make utility. But, why make? What does it really do?įor compiling a single C program, cc command is very helpful. Have you wondered what all these make commands are really making? Sure, we know that it is trying to compile and install the software. When you install any software from source, you typically execute commands like - “make”, “make install”, “make clean”, etc.









Create makefile for c program