简体   繁体   中英

Makefile | Cleaning up after Make - Error: No such file or directory | Error: recipe for target * failed

Situation

Attempting to cleanup after a Makefile compilation.

Errors

These are the error(s) that I'm routinely receiving while attempting to conduct, one would believe to be, a simple cleanup operation.

Errors:

Command:

make linux

g++ Main.o CHARACTER.o ATTRIBUTES.o -o bin/release/Player.sh find *.o -type f -delete  
g++: error: find: No such file or directory
g++: error: f: No such file or directory
g++: error: unrecognized command line option ‘-type’; did you mean ‘-pipe’?

Command:

make linux

g++ Main.o CHARACTER.o ATTRIBUTES.o -o bin/release/Player.sh rm -f *.o
g++: error: rm: No such file or directory
g++: error: unrecognized command line option ‘-f’

Command:

make linux

g++ Main.o CHARACTER.o ATTRIBUTES.o -o bin/release/Player.sh clean
g++: error: clean: No such file or directory
Makefile:2: recipe for target 'linux' failed

Makefile

linux: Main.o CHARACTER.o ATTRIBUTES.o
    g++ Main.o CHARACTER.o ATTRIBUTES.o -o bin/release/Player.sh clean

(alternate command attempt)
    g++ Main.o CHARACTER.o ATTRIBUTES.o -o bin/release/Player.sh -rm -f *.o

(alternate command attempt)
    g++ Main.o CHARACTER.o ATTRIBUTES.o -o bin/release/Player.sh find *.o -type f -delete

win32: Main.o CHARACTER.o ATTRIBUTES.o
    g++ Main.o CHARACTER.o ATTRIBUTES.o -o bin/release/Player.exe cleanWin

main.o: Main.cpp
    g++ -c Main.cpp

CHARACTER.o: src/CHARACTER.cpp include/CHARACTER.h
    g++ -c src/CHARACTER.cpp

ATTRIBUTES.o: src/ATTRIBUTES.cpp include/ATTRIBUTES.h
    g++ -c src/ATTRIBUTES.cpp

clean:
    rm -f *.o

cleanWin:
    del *.o

Summary

Everything except the cleanup routine works apparently fine, however, once cleanup is attempted, I errors for functions that are definitely accessible throughout my OS, whether Win32 or Linux. Can't quite understand why these simple commands are routinely having issues.

Similar Posts

Albeit, my issue is similar to the following post(s), their solution(s) apparently have no effect.

You are adding find *.o -type f -deletefind *.o -type f -delete and the other cleanup commands as arguments to g++ . Put ; between commands. Example:

linux: Main.o CHARACTER.o ATTRIBUTES.o
        g++ Main.o CHARACTER.o ATTRIBUTES.o -o bin/release/Player.sh ;
        clean

Note that this target, linux , doesn't actually produce a linux file. It will produce a binary file called bin/release/Player.sh which is a really bad name for a binary file. .sh is usually reserved for shell scripts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM