Wednesday, August 13, 2008

gcc compiler error when compiling C files: error: stdlib.h: No such file or directory

Trying to compile nrg4iso (http://code.google.com/p/nrg4iso/), I discovered that gcc does not seem to be properly installed. After some searching, I discovered that this is the problem:

http://ubuntuforums.org/showthread.php?t=441404
http://ubuntuforums.org/showthread.php?p=2642484#post2642484

The C compiler is actually split into two packages. The actual compiler (gcc) is packaged separately from the C libraries and header files (libc6-dev). To compile a typical C program, you must install both of these packages. A frequent source of confusion is installing just gcc without libc6-dev. This gives you the compiler, but none of the standard header files.

There is a "meta-package" called build-essential that depends on these packages, along with g++, make and dpkg-dev. So a quick way to get the core C/C++ compiler and libraries is to give the command:

sudo apt-get install build-essential