2

I am getting this error:

~/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

Basically I am trying to install a piece of tomographic software that I downloaded from this webpage

I changed line number 5 in the Makefile to

Home = /home/shah 

Makefile changes

Zanna
  • 70,465
  • Line 5 before any change was HOME = /Users/jon

    Show I add the missing header with hashtag sign or without it. I added it the way you typed above in the Makefile and got the same error. Then I removed the hashtag at the beginning and it gave me following error $ Makefile :2: No such file or directory $ make: ***no rule to make target '<stdlib.h>'. Stop.

    – Shah5105 Nov 20 '18 at 11:25
  • 1
    Different compilers sometimes allow implicit exit() declaration. Just put #include <cstdlib> into the cc files that fail to compile. – Alvin Liang Nov 20 '18 at 11:25
  • 2
    @Shaw No, #include <stdlib.h> or #include <cstdlib> should goes to *.cc, not Makefile – Alvin Liang Nov 20 '18 at 11:28
  • 2
    Thanks Alvin and Zanna. You guys are awesome. I included the #include <stdlib.h> in util.cc and other files,which solved the problem. – Shah5105 Nov 20 '18 at 11:43
  • @abu_bua what version is your gcc? Why do you think it is a makefile error? Did you need to fix the makefile? It is good practice to include that header afaik... – Zanna Nov 20 '18 at 12:38
  • gcc7.3, the Makefile is very old-fashioned -> see makedepend . No need to alter anything. – abu_bua Nov 20 '18 at 12:46

1 Answers1

5

If you try this example you will see that the exit function is defined in #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);
}

The file util.cc, which gives error does not contain the inclusion of StdLib of C. That's why the error.

The mistake was mentioned by Zanna in the previous comment. In any case, ask the author, as he did to compile it. Since the 2003 publication, it seems that it worked for him.