How to clean executable using make clean?

After compiling several *.c and *.h files using make, I cleaned up the object files using make clean. However I don't know how to remove the executable.

my makefile code -->

 CC=gcc CFLAGS=-I. mp1: main.o downloader.o json.o $(CC) -o mp1 main.o downloader.o json.o -I. .PHONY : clean clean : -rm *.o $(objects) 

3 Answers

Your executable seems to be the file mp1. Add this file to the rm command in the clean target:

clean : -rm *.o $(objects) mp1
$ sudo make clean

The above mentioned command will clean all the .o files

2

This command is useful when make is not available in your system.

$ find coding/ -type f -executable | xargs rm

This command removes all executable files in the coding directory.

The first part of the command, the find part lists all the files which are executable.

The second part of the command takes the input from 1st part and gives it to rm command.

xargs - a command that converts its standard input into arguments of another program, look the man page for more info

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like