我有一个简单的 makefile 在 CMD 提示下使用 Cygwin make 可以正常工作。但是通过 Eclipse CDT 中的 Make Target 调用会出现问题。
我的makefile的内容如下:
all: aaa
aaa: bbb.o
    cc -o aaa.exe bbb.o
bbb.o: bbb.c
    cc -c bbb.c
clean:
    rm -f *.exe *.o
在 CMD 中,make all将构建并生成 aaa.exe,同时make clean将清理生成的 EXE 文件。
使用的 make 命令来自{myCygwinFolder}\bin\make.exe. 这可以which make在 CMD 中检查,它给出/usr/bin/make. 此外,Cygwin 路径已添加到我的系统 PATH 中。
但是当我尝试建立一个标准的 Make C 项目时,make clean它就不起作用了。实际上,我已经为我的项目设置了 2 个 Make Targets,make all并且make clean. 发生的事情是,无论我跑哪一个,我总是得到以下错误:
Error launching builder (make all )
(Exec error:The system cannot find the file specified.
)
或者
Error launching builder (make clean)
(Exec error:The system cannot find the file specified.
)
在网上搜索和一些尝试后,我发现 Eclipse 似乎无法正确找到构建器/制作。
因此,我转到项目属性、Builders 选项卡并创建了一个指向我的{myCygwinFolder}\bin\make.exe.
通过此修复,我将能够使用 Make Target 进行编译make all。但是当我使用 Make Target 编译时make clean,Eclipse 仍然尝试运行 Make Target make all。
如果我将干净的部分移动到 makefile 的开头。两个 Make Target 都将运行make clean。似乎 all/clean 标签没有正确传递到 Cygwin make 中,而 Eclipse 只是在 makefile 中完成了第一个任务。
Eclipse中的项目结构设置为:
ProjectRoot
  |__folderA
       |__makefile
       |__bbb.c
       |__*.*
  |__folderB
任何人都可以帮助在 Eclipse 中设置正确的 Make Target 吗?欢迎任何意见。