Reputation: 106
I have a simple makefile works OK under CMD prompt using Cygwin make. But have problem by invoking through Make Target in Eclipse CDT.
The content of my makefile is as below:
all: aaa
aaa: bbb.o
cc -o aaa.exe bbb.o
bbb.o: bbb.c
cc -c bbb.c
clean:
rm -f *.exe *.o
When in CMD, make all
will build and generate aaa.exe, while make clean
will clean the EXE file generated.
The make command used is from {myCygwinFolder}\bin\make.exe
. This can be checked by which make
in CMD, which gives /usr/bin/make
. Also, the Cygwin path is added in my system PATH.
But when I try to set up a Standard Make C Project, the make clean
just doesn't work. Actually, I have setup 2 Make Targets for my project, make all
and make clean
. The things happened was, no matter which one I ran, I always got the following error:
Error launching builder (make all )
(Exec error:The system cannot find the file specified.
)
or
Error launching builder (make clean)
(Exec error:The system cannot find the file specified.
)
After searching online and some tries, I found it seems Eclipse couldn't find the builder/make properly.
So, I went to the project properties, Builders tab and created a new builder that point to my {myCygwinFolder}\bin\make.exe
.
With this fix, I would be able to compile with Make Target make all
. But when I compile with Make Target make clean
, Eclipse still tries to run Make Target make all
.
If I move clean section to the beginning of the makefile. Both Make Target will all run make clean
. It seems the all/clean tags are not passed into Cygwin make correctly, and Eclipse just make the first task in makefile.
The project structure setup in Eclipse is:
ProjectRoot
|__folderA
|__makefile
|__bbb.c
|__*.*
|__folderB
Could anyone can help in setting up correct Make Target in Eclipse? Any comments are welcomed.
Upvotes: 2
Views: 1194
Reputation: 5467
The issue is path. When you are in windows environment from eclipse, you'll need to adjust the path to ensure that make can be found. I routinely used to have to have to change the default build command to get around this back in my days of using the CDT
Upvotes: 0