確認:***ターゲットはありません。止める

確認:***ターゲットはありません。止める

makeコードのコマンドが次のような場合にエラーが発生するのはなぜですかmake: *** No targets. Stop.

    NAME := program
FLAG := -std=c11 -Wall -Wextra -Werror -Wpedantic

all: $(NAME)

$(NAME): *.c
  clang $(FLAG) -o $(NAME) *.c -lm

clean:
  rm -rf $(NAME)

reinstall: clean all

ベストアンサー1

このエラーの主な原因は、null Makefile(またはmakefile)があることです。

touch makefile
make
make: *** No targets.  Stop.

上記のように使用しても、このエラーを引き起こすNULL値がある可能性Makefileがあります。makefile未使用のファイルを削除してください。

また、集中線は空白ではなくインデントMakefileする必要があります。tab

$(NAME): *.c
        clang $(FLAG) -o $(NAME) *.c -lm

これを忘れた場合、他のエラーが発生します。

整合性作業のシナリオ:

# Nothing in the current directory
ls
make
  make: *** No targets specified and no makefile found.  Stop.
# Create "Makefile" and list it
printf 'thing:\n\tdate >thing\n' >Makefile
cat Makefile
  thing:
          date >thing
# Run the "Makefile" recipe    
make
  date >thing
# Create a bogus empty "makefile"
touch makefile
make
  make: *** No targets.  Stop.

おすすめ記事