16
I am using various stdlib functions like srand(), etc. I have the line
#include <stdlib.h>
at the top of my code.
I entered this on the command line:
# find / -name stdlib.h
find: `/home/dmurvihill/.gvfs: permission denied
/usr/include/stdlib.h
/usr/include/bits/stdlib.h
So, stdlib.h is clearly in /usr/include.
My preprocessor:
# gcc -print-prog-name=cc1
/usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1
My preprocessor's default search path:
# /usr/libexec/gcc/x86_64-redhat-linux/4.5.1/cc1 -v
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/x86_64-redhat-linux/4.5.1/include
/usr/include
End of search list.
So, stdlib.h is clearly in /usr/include, which is most definitely supposed to be searched by my preprocessor, but I still get this error!
/path/to/cpa_sample_code_main.c:15:20: fatal error: stdlib.h: No such file or directory
compilation terminated
Update
A program I wrote to test this code:
#include <stdio.h>
#include <stdlib.h>
#include <linux/time.h>
int main()
{
printf("Hello, World!\n");
printf("Getting time...\n");
time_t seconds;
time(&seconds);
printf("Seeding generator...\n");
srand((unsigned int)seconds);
printf("Getting random number...\n");
int value = rand();
printf("It is %d!",value);
printf("Goodbye, cruel world!");
return 0;
}
The command
gcc -H -v -fsyntax-only stdlib_test.c
output
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_