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

  • 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
  • Related on Stack Overflow – Zanna Nov 20 '18 at 12:37

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");

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


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.