Makefile 42:目标“util.o”的配方失败

Sha*_*105 2 compiling c++ makefile

我收到此错误:

~/Distrib$ make all
/usr/bin/g++ -O3 util.cc -I/home/shah/Distrib
util.cc: In function 'into countLines(const char*)':
util:19:8: error: 'exit' was not declared in this scope
  exit(1);
        ^
Makefile:42: recipe for target 'util.o' failed
make: *** [util.o] Error 1
Run Code Online (Sandbox Code Playgroud)

基本上我想安装一个我从这个网页下载的断层扫描软件

我将 Makefile 中的第 5 行更改为

Home = /home/shah 
Run Code Online (Sandbox Code Playgroud)

Makefile 更改

Car*_*ret 5

如果你尝试这个例子,你会看到退出函数是在#include 中定义的

#include <stdio.h>
#include <stdlib.h>

int main () {
   printf("Start of the program....\n");

   printf("Exiting the program....\n");
   exit(0);

   printf("End of the program....\n");

   return(0);
}
Run Code Online (Sandbox Code Playgroud)

给出错误的 util.cc 文件不包含包含 C 的 StdLib。这就是错误的原因。

Zanna在之前的评论中提到了这个错误。无论如何,问问作者,就像他编译它一样。自 2003 年出版以来,它似乎对他有用。