Tropilio
Tropilio

Reputation: 1505

MSYS make.exe command won't do anything ("Nothing to be done for...")

Ok, hello everyone. I searched a lot to see if I could find an answer to my question, but I couldn't. I installed the latest versions of MinGW and MSYS on Windows 10. I created a very simple C file, based on Zed Shaw's guide (Learn C the hard way), which looks like this:

#include <stdio.h>

int main(int argc, char *argv[])
{
    int distance = 666;

    printf("You are %d miles away. \n", distance);

    return 0;

}

Now, according to Shaw's guide, I should be able to compile the file just by using the following command:

make .\es1.c

And it should automatically recognise that I'm compiling a C source file and use some default options, like "-o es1", even without a makefile. The problem is that when I try to compile it using MSYS's make, I get this:

make.exe": Nothing to be done for `.\es1.c'.

And I can't make it compile in any way. If I call directly the gcc compiler, in this way:

gcc .\es1.c -o es1

It works. What I am I doing wrong?

Thank you everybody.

Upvotes: 0

Views: 1216

Answers (2)

Vroomfondel
Vroomfondel

Reputation: 2898

The problem maybe is with the schizophrenic interaction of Unix build tools and Windows program execution:

user@dogbert ~/foo
$ echo "int main() { return 0; }" > foo.c

user@dogbert ~/foo
$ cat foo.c
int main() { return 0; }

So far so good. Now make it - no makefile needed.

user@dogbert ~/foo
$ make foo
cc     foo.c   -o foo

Although the target was named foo, foo.exe was made.

user@dogbert ~/foo
$ ls
foo.c  foo.exe

user@dogbert ~/foo
$ ./foo

user@dogbert ~/foo
$ ./foo.exe

It seems that foo and foo.exe are synonyms on cygwin.

user@dogbert ~/foo
$ make foo
make: foo is up to date

user@dogbert ~/foo
$

Upvotes: 0

Florian Weimer
Florian Weimer

Reputation: 33719

You need to supply the target (what is to be built) to the make command, not the dependencies of the build. The make tool will always consider non-generated source file as up-to-date because, by definition, there is nothing from which they can be built.

In your case, try this:

make es1.exe

(I assume you are on Windows and your makefile is set up to create the target with an .exe extension.)

Upvotes: 1

Related Questions