简单的生成文件。为啥 .exe 被创建然后被 make 删除?

Posted

技术标签:

【中文标题】简单的生成文件。为啥 .exe 被创建然后被 make 删除?【英文标题】:Simple makefile. Why is .exe being created and then deleted by make?简单的生成文件。为什么 .exe 被创建然后被 make 删除? 【发布时间】:2014-08-10 18:15:31 【问题描述】:

我的另一个问题是 netbeans 没有创建 .exe,但 netbeans 没有错误输出。这仍然没有解决。由于我被要求在没有 IDE 的情况下仅使用“make”来编译这个项目,而我以前从未这样做过,所以我创建了这个简单的程序来了解 makefile。

//main.cpp
int main()  
  int i = 1;
  return 0;

我的生成文件如下所示:

project000: main.o
    g++ -Wall main.o -o project000

main.o: main.cpp
    g++ -Wall -c main.cpp

clean:
    rm *.o project000

当我进入项目目录并执行'make'时,.o文件被创建,我可以看到project000.exe被创建然后被删除!因此,我通过将 makefile 缩短为

来检查是否每次都执行 makefile 的“干净”部分
project000: main.o
    g++ -Wall main.o -o project000

main.o: main.cpp
    g++ -Wall -c main.cpp

但同样的事情也会发生。正在创建 .exe,然后将其删除。

有人吗?

'make -d' 的输出(可能不包括开头,因为我在运行时提示行太少)

 Trying implicit prerequisite `Makefile.l'.
 Looking for a rule with intermediate file `Make
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Trying pattern rule with stem `Makefile.l'.
 Trying implicit prerequisite `Makefile.l,v'.
 Trying pattern rule with stem `Makefile.l'.
 Trying implicit prerequisite `RCS/Makefile.l,v
 Trying pattern rule with stem `Makefile.l'.
 Trying implicit prerequisite `RCS/Makefile.l'.
 Trying pattern rule with stem `Makefile.l'.
 Trying implicit prerequisite `s.Makefile.l'.
 Trying pattern rule with stem `Makefile.l'.
 Trying implicit prerequisite `SCCS/s.Makefile.
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.w'.
 Looking for a rule with intermediate file `Make
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Trying pattern rule with stem `Makefile.w'.
 Trying implicit prerequisite `Makefile.w,v'.
 Trying pattern rule with stem `Makefile.w'.
 Trying implicit prerequisite `RCS/Makefile.w,v
 Trying pattern rule with stem `Makefile.w'.
 Trying implicit prerequisite `RCS/Makefile.w'.
 Trying pattern rule with stem `Makefile.w'.
 Trying implicit prerequisite `s.Makefile.w'.
 Trying pattern rule with stem `Makefile.w'.
 Trying implicit prerequisite `SCCS/s.Makefile.
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Mak
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.cc'.
 Looking for a rule with intermediate file `Makef
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Trying pattern rule with stem `Makefile.cc'.
 Trying implicit prerequisite `Makefile.cc,v'.
 Trying pattern rule with stem `Makefile.cc'.
 Trying implicit prerequisite `RCS/Makefile.cc,v
 Trying pattern rule with stem `Makefile.cc'.
 Trying implicit prerequisite `RCS/Makefile.cc'.
 Trying pattern rule with stem `Makefile.cc'.
 Trying implicit prerequisite `s.Makefile.cc'.
 Trying pattern rule with stem `Makefile.cc'.
 Trying implicit prerequisite `SCCS/s.Makefile.c
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.C'.
 Looking for a rule with intermediate file `Makef
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Trying pattern rule with stem `Makefile.C'.
 Trying implicit prerequisite `Makefile.C,v'.
 Trying pattern rule with stem `Makefile.C'.
 Trying implicit prerequisite `RCS/Makefile.C,v'
 Trying pattern rule with stem `Makefile.C'.
 Trying implicit prerequisite `RCS/Makefile.C'.
 Trying pattern rule with stem `Makefile.C'.
 Trying implicit prerequisite `s.Makefile.C'.
 Trying pattern rule with stem `Makefile.C'.
 Trying implicit prerequisite `SCCS/s.Makefile.C
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.cpp'.
 Looking for a rule with intermediate file `Makef
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Trying pattern rule with stem `Makefile.cpp'.
 Trying implicit prerequisite `Makefile.cpp,v'.
 Trying pattern rule with stem `Makefile.cpp'.
 Trying implicit prerequisite `RCS/Makefile.cpp,
 Trying pattern rule with stem `Makefile.cpp'.
 Trying implicit prerequisite `RCS/Makefile.cpp'
 Trying pattern rule with stem `Makefile.cpp'.
 Trying implicit prerequisite `s.Makefile.cpp'.
 Trying pattern rule with stem `Makefile.cpp'.
 Trying implicit prerequisite `SCCS/s.Makefile.c
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.p'.
 Looking for a rule with intermediate file `Makef
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.web'.
 Trying pattern rule with stem `Makefile.p'.
 Trying implicit prerequisite `Makefile.p,v'.
 Trying pattern rule with stem `Makefile.p'.
 Trying implicit prerequisite `RCS/Makefile.p,v'
 Trying pattern rule with stem `Makefile.p'.
 Trying implicit prerequisite `RCS/Makefile.p'.
 Trying pattern rule with stem `Makefile.p'.
 Trying implicit prerequisite `s.Makefile.p'.
 Trying pattern rule with stem `Makefile.p'.
 Trying implicit prerequisite `SCCS/s.Makefile.p
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.web'.
 Looking for a rule with intermediate file `Make
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Trying pattern rule with stem `Makefile.web'.
 Trying implicit prerequisite `Makefile.web,v'.
 Trying pattern rule with stem `Makefile.web'.
 Trying implicit prerequisite `RCS/Makefile.web
 Trying pattern rule with stem `Makefile.web'.
 Trying implicit prerequisite `RCS/Makefile.web
 Trying pattern rule with stem `Makefile.web'.
 Trying implicit prerequisite `s.Makefile.web'.
 Trying pattern rule with stem `Makefile.web'.
 Trying implicit prerequisite `SCCS/s.Makefile.
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.f'.
 Looking for a rule with intermediate file `Makef
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.F'.
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.r'.
 Trying pattern rule with stem `Makefile.f'.
 Trying implicit prerequisite `Makefile.f,v'.
 Trying pattern rule with stem `Makefile.f'.
 Trying implicit prerequisite `RCS/Makefile.f,v'
 Trying pattern rule with stem `Makefile.f'.
 Trying implicit prerequisite `RCS/Makefile.f'.
 Trying pattern rule with stem `Makefile.f'.
 Trying implicit prerequisite `s.Makefile.f'.
 Trying pattern rule with stem `Makefile.f'.
 Trying implicit prerequisite `SCCS/s.Makefile.f
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.F'.
 Looking for a rule with intermediate file `Make
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Trying pattern rule with stem `Makefile.F'.
 Trying implicit prerequisite `Makefile.F,v'.
 Trying pattern rule with stem `Makefile.F'.
 Trying implicit prerequisite `RCS/Makefile.F,v
 Trying pattern rule with stem `Makefile.F'.
 Trying implicit prerequisite `RCS/Makefile.F'.
 Trying pattern rule with stem `Makefile.F'.
 Trying implicit prerequisite `s.Makefile.F'.
 Trying pattern rule with stem `Makefile.F'.
 Trying implicit prerequisite `SCCS/s.Makefile.
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.r'.
 Looking for a rule with intermediate file `Make
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Ma
 Trying pattern rule with stem `Makefile.r'.
 Trying implicit prerequisite `Makefile.r,v'.
 Trying pattern rule with stem `Makefile.r'.
 Trying implicit prerequisite `RCS/Makefile.r,v
 Trying pattern rule with stem `Makefile.r'.
 Trying implicit prerequisite `RCS/Makefile.r'.
 Trying pattern rule with stem `Makefile.r'.
 Trying implicit prerequisite `s.Makefile.r'.
 Trying pattern rule with stem `Makefile.r'.
 Trying implicit prerequisite `SCCS/s.Makefile.
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Make
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Make
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.s'.
 Looking for a rule with intermediate file `Makef
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.S'.
 Trying pattern rule with stem `Makefile.s'.
 Trying implicit prerequisite `Makefile.s,v'.
 Trying pattern rule with stem `Makefile.s'.
 Trying implicit prerequisite `RCS/Makefile.s,v'
 Trying pattern rule with stem `Makefile.s'.
 Trying implicit prerequisite `RCS/Makefile.s'.
 Trying pattern rule with stem `Makefile.s'.
 Trying implicit prerequisite `s.Makefile.s'.
 Trying pattern rule with stem `Makefile.s'.
 Trying implicit prerequisite `SCCS/s.Makefile.s
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.S'.
 Looking for a rule with intermediate file `Make
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Trying pattern rule with stem `Makefile.S'.
 Trying implicit prerequisite `Makefile.S,v'.
 Trying pattern rule with stem `Makefile.S'.
 Trying implicit prerequisite `RCS/Makefile.S,v
 Trying pattern rule with stem `Makefile.S'.
 Trying implicit prerequisite `RCS/Makefile.S'.
 Trying pattern rule with stem `Makefile.S'.
 Trying implicit prerequisite `s.Makefile.S'.
 Trying pattern rule with stem `Makefile.S'.
 Trying implicit prerequisite `SCCS/s.Makefile.
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Make
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.mod'.
 Looking for a rule with intermediate file `Makef
 Avoiding implicit rule recursion.
 Avoiding implicit rule recursion.
 Trying pattern rule with stem `Makefile.mod'.
 Trying implicit prerequisite `Makefile.mod,v'.
 Trying pattern rule with stem `Makefile.mod'.
 Trying implicit prerequisite `RCS/Makefile.mod,
 Trying pattern rule with stem `Makefile.mod'.
 Trying implicit prerequisite `RCS/Makefile.mod'
 Trying pattern rule with stem `Makefile.mod'.
 Trying implicit prerequisite `s.Makefile.mod'.
 Trying pattern rule with stem `Makefile.mod'.
 Trying implicit prerequisite `SCCS/s.Makefile.m
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Makef
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Makef
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Makef
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Makef
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Makef
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Makef
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Makef
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Makef
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Makef
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Makef
 Trying pattern rule with stem `Makefile'.
 Rejecting impossible implicit prerequisite `Makef
 Trying pattern rule with stem `Makefile'.
 Trying implicit prerequisite `Makefile.sh'.
 Looking for a rule with intermediate file `Makefi
 Avoiding implicit rule recursion.
 Trying pattern rule with stem `Makefile.sh'.
 Trying implicit prerequisite `Makefile.sh,v'.
 Trying pattern rule with stem `Makefile.sh'.  
 Trying implicit prerequisite `RCS/Makefile.sh,v'
 Trying pattern rule with stem `Makefile.sh'.
 Trying implicit prerequisite `RCS/Makefile.sh'.
 Trying pattern rule with stem `Makefile.sh'.
 Trying implicit prerequisite `s.Makefile.sh'.
 Trying pattern rule with stem `Makefile.sh'.
 Trying implicit prerequisite `SCCS/s.Makefile.sh
 No implicit rule found for `Makefile'.
 Finished prerequisites of target file `Makefile'.
 No need to remake target `Makefile'.
 Updating goal targets....
 Considering target file `project000.exe'.
 File `project000.exe' does not exist.
 Considering target file `main.o'.
 Considering target file `main.cpp'.
 Looking for an implicit rule for `main.cpp'.
 Trying pattern rule with stem `main.cpp'.
 Trying implicit prerequisite `main.cpp,v'.
 Trying pattern rule with stem `main.cpp'.
 Trying implicit prerequisite `RCS/main.cpp,v'.
 Trying pattern rule with stem `main.cpp'.
 Trying implicit prerequisite `RCS/main.cpp'.
 Trying pattern rule with stem `main.cpp'.
 Trying implicit prerequisite `s.main.cpp'.
 Trying pattern rule with stem `main.cpp'.
 Trying implicit prerequisite `SCCS/s.main.cpp'
 Looking for a case-insensitive implicit rule f
 Trying pattern rule with stem `main.cpp'.
 Trying implicit prerequisite `main.cpp,v'.
 Trying pattern rule with stem `main.cpp'.
 Trying implicit prerequisite `RCS/main.cpp,v'.
 Trying pattern rule with stem `main.cpp'.
 Trying implicit prerequisite `RCS/main.cpp'.
 Trying pattern rule with stem `main.cpp'.
 Trying implicit prerequisite `s.main.cpp'.
 Trying pattern rule with stem `main.cpp'.
 Trying implicit prerequisite `SCCS/s.main.cpp'
 No implicit rule found for `main.cpp'.
 Finished prerequisites of target file `main.cp
 No need to remake target `main.cpp'.
 Finished prerequisites of target file `main.o'.
 Prerequisite `main.cpp' is older than target `ma
 No need to remake target `main.o'.
 Finished prerequisites of target file `project000.
 Must remake target `project000.exe'.
 g++ -Wall main.o -o project000.exe
 Putting child 0x0a020398 (project000.exe) PID 5840
 Live child 0x0a020398 (project000.exe) PID 5840
 Reaping winning child 0x0a020398 PID 5840
 Removing child 0x0a020398 PID 5840 from chain.
 Successfully remade target file `project000.exe'.

制作 -Rrd 输出

 This program built for i686-pc-msys
 Reading makefiles...
 Reading makefile `Makefile'...
 Updating makefiles....
 Considering target file `Makefile'.
 Looking for an implicit rule for `Makefile'.
 Looking for a case-insensitive implicit rule for `Makefile'.
 No implicit rule found for `Makefile'.
 Finished prerequisites of target file `Makefile'.
 No need to remake target `Makefile'.
 Updating goal targets....
 Considering target file `project000.exe'.
 File `project000.exe' does not exist.
 Considering target file `main.o'.
 Considering target file `main.cpp'.
 Looking for an implicit rule for `main.cpp'.
 Looking for a case-insensitive implicit rule for `main.cpp'.
 No implicit rule found for `main.cpp'.
 Finished prerequisites of target file `main.cpp'.
 No need to remake target `main.cpp'.
 Finished prerequisites of target file `main.o'.
 Prerequisite `main.cpp' is older than target `main.o'.
 No need to remake target `main.o'.
 Finished prerequisites of target file `project000.exe'.
 Must remake target `project000.exe'.
 g++ -Wall main.o -o project000.exe
 Putting child 0x0a01a270 (project000.exe) PID 6796 on the chain.
 Live child 0x0a01a270 (project000.exe) PID 6796
 Reaping winning child 0x0a01a270 PID 6796
 Removing child 0x0a01a270 PID 6796 from chain.
 Successfully remade target file `project000.exe'.

【问题讨论】:

如果将project000 替换为project000.exe 会发生什么? make -d的结果粘贴到这里。 您不会碰巧有病毒扫描程序或其他过度急切的文件系统监控应用程序处于活动状态,对吗?尝试自己运行g++ 命令以排除make 是罪魁祸首。 我不同意。为什么不应该有人因为病毒扫描程序而遇到同样的问题(正在创建,然后删除)?我添加了另一个标签(防病毒)。 @Earnie:您能否在您的问题中添加“解决方案”,以便读者无需阅读此处的 cmets 即可解决问题?或者只是发布一个答案 【参考方案1】:

Avast Antivir 处于静默模式,它会将每个新的 .exe 都置于隔离区,而不会通知我。这就是 .exe 在创建后立即被删除的原因。

【讨论】:

一旦允许,请将此标记为答案。 计算小时数 ;-)

以上是关于简单的生成文件。为啥 .exe 被创建然后被 make 删除?的主要内容,如果未能解决你的问题,请参考以下文章

为啥“.exe”的文件老是被杀软干掉

蜡烛.exe 访问被拒绝

如何创建exe文件

golang生成的exe文件打开就闪退为啥 输出hello world也是

如何生成可执行exe文件

为啥 URL 在存储然后从本地文件系统检索时会被截断?