When I build a project usng Eclipse I get the following error regarding the Makefile:µ
Type make: *** No rule to make target `hello.exe', needed by `all'. Stop.
My Makefile is this:
all: hello
hello: main.o factorial.o hello.o
g++ main.o factorial.o hello.o -o hello
main.o: main.cpp
g++ -c main.cpp
factorial.o: factorial.cpp
g++ -c factorial.cpp
hello.o: hello.cpp
g++ -c hello.cpp
clean:
rm -rf *o hello
Does anyone know which is my mistake? Thank you in advance.
1st, good luck developing with Eclipse, you need a lot of Zen for that
2nd, a quick recap about how to read a makefile:
target: requiredTarget(optional)
how to generate the target
so, as you can see, reading the first line of your makefile is like saying: " I have a target named all and this target requires the target hello in order to be generated ".
Now the target all
is a special one, it's the one that is implicit, so when you or your IDE just type make
in your shell make all
is implied ( of course you can specify your target with make
, the special case is just applied when no building target is specified via the command line ).
The chain begins with make
or an explicit make all
that always leads to build the all
target, the all
target calls in the hello
target but since you are on Windows, the suffix .exe
is automatically added and your make
can't find a target named hello.exe
.
Basically you need to manage your OS specific building steps and you have to edit that makefile to let this work, or you can wait for someone that is more into Eclipse to see if there is a good makefile-related option to manage this platform-specific stuff.
a good introduction is http://www.cprogramming.com/tutorial/makefiles.html
consider QTcreator for C++ developing.
I don't have idea about Eclipse but whatever the Makefile
you have will work fine in Linux. try to change target name after all
like this and check out
all: hello.exe
hello.exe: main.o factorial.o hello.o
g++ main.o factorial.o hello.o -o hello.exe
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.