Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
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
add comment

4 Answers 4

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
add comment

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
1  
You can use ''--directory='' to direct make to the right directory: make --directory=/home/me/Desktop/folderWithMakefile –  falstaff Sep 9 '11 at 6:55
add comment

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

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

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.