1

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.

Justin Byrne
  • 179
  • 1
  • 2
  • 12
  • I don't get where does that `find` comes from... – YSC Sep 26 '19 at 16:20
  • 1
    There's no way you're getting that output from the makefile you've showed us. Please provide the _actual_ makefile you're using, or at least the relevant sections. Also you have sections named `Command` but you don't actually show the command that you typed; please show the make command you ran in your question as well. – MadScientist Sep 26 '19 at 16:23
  • 1
    I think those _are_ the commands OP typed. That's what I assumed when I answered anyway :-) – Ted Lyngmo Sep 26 '19 at 16:26
  • original commands are `make linux` and `make win32` under their respective OS's – Justin Byrne Sep 26 '19 at 16:41
  • @NobleCloud Which command did you give to produce the `find` llne? Put the actual commands you gave at the command line in the question. – Ted Lyngmo Sep 26 '19 at 16:45
  • `make linux`, however, rather than `rm -f *.o` for the `clean` command, I had `find *.o -type f`... apologize for the omission. – Justin Byrne Sep 26 '19 at 16:47
  • [Edit](https://stackoverflow.com/posts/58120833/edit) the question to clarify. Put the actual commands and the output they gave in the question. We can't help if we have to guess. – Ted Lyngmo Sep 26 '19 at 16:48
  • Didn't mean to confuse so many. Made some alterations. If there's further confusion please let me know. – Justin Byrne Sep 26 '19 at 17:01

1 Answers1

3

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.

Ted Lyngmo
  • 93,841
  • 5
  • 60
  • 108
  • With regards to your `make ` suggestion. I get that there are various ways to format a Makefile, however, would you mind pointing out a boilerplate, or "general method" or a "proper" way of formatting a rudimentary Makefile? – Justin Byrne Sep 26 '19 at 16:38
  • It's a different question really. Your should however make sure that the targets (like `win32`) actually produces a file called `win32` - or else it'll try to rebuild it every time. Also make sure that the commands are valid. `g++ Main.o CHARACTER.o ATTRIBUTES.o -o bin/release/Player.sh clean` seems invalid for example. `clean` will become an argument to `g++`. – Ted Lyngmo Sep 26 '19 at 16:44
  • @NobleCloud You also need a `` before the actual commands in the Makefile. It looks like you don't have that. – Ted Lyngmo Sep 26 '19 at 16:52
  • I do have actual single `` within the actual file. Not sure how else to illustrate it here. Apologies. – Justin Byrne Sep 26 '19 at 17:00
  • In addition to your remark on placing a terminator `;` or a semi-colon on the end of each statement. Can this be accomplished through a Makefile. Attempted myself, without much success, and can't locate documentation indicating its usage. – Justin Byrne Sep 26 '19 at 17:03