Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
I guess because how is the command going to work if there‘s nothing to work with. – Uri Herrera Sep 9 '11 at 6:54
up vote 3 down vote accepted

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]
share|improve this answer

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...

share|improve this answer
You can use ''--directory='' to direct make to the right directory: make --directory=/home/me/Desktop/folderWithMakefile – falstaff Sep 9 '11 at 6:55

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

share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.