2

I'm unable to successfully make a file when I do the following command

make /home/me/Desktop/folderWithMakefile

However an executable is created when I do the following

cd /home/me/Desktop/folderWithMakefile
/home/me/Desktop/folderWithMakefile 
make
1
  • I guess because how is the command going to work if there‘s nothing to work with. Sep 9, 2011 at 6:54

4 Answers 4

3

The make command looks for the Makefile in the current directory by default. For the first command you listed to work, you would need a Makefile in the current directory that contained a /home/me/Desktop/folderWithMakefile target.

If you want to run make in the context of a different directory (and hence pick up a different Makefile), you can use the -C option. For example:

make -C /home/me/Desktop/folderWithMakefile [target]
2

The Makefile contains relative paths, which are relative to your current directory. When you aren't in the directory where the codefiles are, the commands will not find the files needed...

1
  • 1
    You can use ''--directory='' to direct make to the right directory: make --directory=/home/me/Desktop/folderWithMakefile
    – falstaff
    Sep 9, 2011 at 6:55
0

The argument given to make is not the directory to use but the make-target that shoud be build.

0

use make -C /home/me/Desktop/folderWithMakefile

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .