Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# specify the object files . . . OBJ = main.o functions.o # specify the compiler CC = gcc # this is the cross platform

# specify the object files ...
OBJ = main.o functions.o
# specify the compiler
CC = gcc # this is the cross platform standard C compiler
CXX = g++ # this is the GNU C++ compiler
#CXX = CC # Solaris C++ compiler
# specify the compiler options
CFLAGS =-g
# specify the target C files
TARGET_SRC = main.c functions.c
# specify variables
EXE_NAME = demo
# leads comments in a line
# Build all: default target
all: $(EXE_NAME)
# Separate compilation to build object files
main.o: main.c functions.h
$(CC)-c $(CFLAGS) main.c
function.o: functions.c functions.h
$(CC)-c $(CFLAGS) functions.c
# linking
#demo is a target which depends upon main.o and functions.o
#"gcc main.o functions.o -o demo" is the command to produce the executable file
#You need to use a TAB before gcc
$(EXE_NAME): $(OBJ)
$(CC) $(OBJ)-o $(EXE_NAME)
# Testing
check: all
./$(EXE_NAME)
# Debugging with gdb
g: all
gdb ./$(EXE_NAME)
# Valgrind
valgrind:
valgrind --leak-check=full --show-leak-kinds=all ./$(EXE_NAME)
# Clean up all build targets so that one may get a clean build
clean:
rm -f *.o $(EXE_NAME)*core*
fix the valgrind issue in this make file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions