1
votes

I'm new to using makefiles for my projects, and I decided to start since I got tired of writing out all of the commands and arguments.

The current makefile that I have looks like this:

run_program:
        CUDA_VISIBLE_DEVICES=1
        python DIR/main.py --setup2

When I run this program using the following command:

make run_program

I get the following error:

make: *** No rule to make target 'run_program'.  Stop

I've made sure that the makefile is in the appropriate directory and that there are no spelling errors of the sort, but I'm having trouble figuring out what I did wrong. I've checked others answers such as gcc makefile error: “No rule to make target …” but I'm not sure how to apply it to my case.

Any tips or advice are greatly appreciated. Thanks in advance.

1
How odd. What happens when you just make?Beta
I receive the error message make: *** No targets specified and no makefile found. Stop.Sean
Curiouser and curiouser. What is the name of your makefile?Beta
The name of my makefile is make.mk.Sean
I have another makefile named makefile.mk and this doesn't work either. :(Sean

1 Answers

2
votes

Per 'make' info page:

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.

If you name your makefile in other name, you will have to use the '-f'. While this is a good practice to name makefiles with '.mk' suffix (e.g., makefile for sub projects), most projects will name the "main" makefile to match on the the defaults, usually 'Makefile'.