开发者

make file issue : always spits out "Nothing to be done for `make.w'."

I have 3 files Head.cpp , Head.h and Hello.cpp . I am trying to build a make for the compilation process. My makefile is make.w

Hello :   Head.o Hello.o
          g++ -o Head.o Hello.o

Head.o :  Head.cpp
          g++ -o Head.cpp

Hello.o:  Hello.cpp
          g++ -o Hello.cpp

every time I type the command make make.w - I get " Nothing to make fot ma开发者_Go百科ke.w" . I dont get why this is happening and how to resolve the same.


Since you are calling the make with a non-default make file which is makefile or Makefile you need to use the -f option as:

make -f make.w
     ^^

Looks like you are currently calling it as:

make make.w

which does not work. It tell make to make the target make.w in the default makefile.

Also When converting from .c to .o you need to use the -c compiler flag which tells the compiler to just compile but don't link. Also when using -c you don't need -o, the compiler will generate the <filename>.o for you.

Head.o :  Head.cpp
          g++ -c  Head.cpp
              ^^

Hello.o:  Hello.cpp
          g++ -c  Hello.cpp
              ^^

And finally you are missing the name of the executable Hello on the compile line:

Hello :   Head.o Hello.o
          g++ -o Head Head.o Hello.o
                 ^^^^


make make.w means "Make target make.w in default makefile named Makefile".

You want to specify your makefile, so you want make -f make.w


You need a -f in front of the makefile name.

make -f make.w

You may want to specify the target to be built as well

make -f make.w Hello
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜