Все наручники

Я больше не могу запускать Makefile. Я получаю:

./Makefile: line 1: sorter:: command not found

Содержимое Makefile:

sorter: sorter.o gcc sorter.o -o sorter sorter.o: sorter.c gcc -c sorter.c test: ./run_test check: c_style_check sorter.c clean: rm -f sorter *.o

Что удивительно, так это то, что все мои файлы Makefile были использованы только вчера. Я не знаю, что случилось, я думаю, что у моего Lubuntu было обновление, но это все.

3
задан 15 October 2017 в 16:49

3 ответа

Ошибка возникает из-за того, что вы ожидаете, что ваша оболочка будет понимать и запускать файл.

Makefiles не предназначены для исполнения - они приводятся в качестве входных данных для команды make, например. make -f Makefile - или просто make, так как он будет искать текущий каталог для файла с именами по умолчанию, такими как Makefile, makefile.

Из man make:

   To  prepare to use make, you must write a file called the makefile that
   describes the relationships among files in your program, and the states
   the  commands for updating each file.  In a program, typically the exe‐
   cutable file is updated from object files, which are in  turn  made  by
   compiling source files.

   Once  a  suitable  makefile  exists,  each  time you change some source
   files, this simple shell command:

          make

   suffices to perform all necessary  recompilations.   The  make  program
   uses  the  makefile  description and the last-modification times of the
   files to decide which of the files need to be  updated.   For  each  of
   those files, it issues the commands recorded in the makefile.

   make  executes  commands  in  the makefile to update one or more target
   names, where name is typically a program.  If no -f option is  present,
   make  will  look for the makefiles GNUmakefile, makefile, and Makefile,
   in that order.
7
ответ дан 22 May 2018 в 17:32
  • 1
    При этом вы можете использовать shebang для make-файлов, чтобы заставить их вести себя как исполняемые файлы: #!/usr/bin/make -f – David Foerster 15 October 2017 в 16:51

Ошибка возникает из-за того, что вы ожидаете, что ваша оболочка будет понимать и запускать файл.

Makefiles не предназначены для исполнения - они приводятся в качестве входных данных для команды make, например. make -f Makefile - или просто make, так как он будет искать текущий каталог для файла с именами по умолчанию, такими как Makefile, makefile.

Из man make:

To prepare to use make, you must write a file called the makefile that describes the relationships among files in your program, and the states the commands for updating each file. In a program, typically the exe‐ cutable file is updated from object files, which are in turn made by compiling source files. Once a suitable makefile exists, each time you change some source files, this simple shell command: make suffices to perform all necessary recompilations. The make program uses the makefile description and the last-modification times of the files to decide which of the files need to be updated. For each of those files, it issues the commands recorded in the makefile. make executes commands in the makefile to update one or more target names, where name is typically a program. If no -f option is present, make will look for the makefiles GNUmakefile, makefile, and Makefile, in that order.
7
ответ дан 18 July 2018 в 05:17

Ошибка возникает из-за того, что вы ожидаете, что ваша оболочка будет понимать и запускать файл.

Makefiles не предназначены для исполнения - они приводятся в качестве входных данных для команды make, например. make -f Makefile - или просто make, так как он будет искать текущий каталог для файла с именами по умолчанию, такими как Makefile, makefile.

Из man make:

To prepare to use make, you must write a file called the makefile that describes the relationships among files in your program, and the states the commands for updating each file. In a program, typically the exe‐ cutable file is updated from object files, which are in turn made by compiling source files. Once a suitable makefile exists, each time you change some source files, this simple shell command: make suffices to perform all necessary recompilations. The make program uses the makefile description and the last-modification times of the files to decide which of the files need to be updated. For each of those files, it issues the commands recorded in the makefile. make executes commands in the makefile to update one or more target names, where name is typically a program. If no -f option is present, make will look for the makefiles GNUmakefile, makefile, and Makefile, in that order.
7
ответ дан 24 July 2018 в 18:17

Другие вопросы по тегам:

Похожие вопросы: