I had trouble building this on CentOS 5-7 (both 32 and 64 bit). There were two separate issues:
- The
gethostname() function was not found in unistd.h
This is caused by a GNU feature macro requirement test. It can be fixed by adding -D_GNU_SOURCE to the compiler options in the Makefile. Another way to fix it is to change -std=c99 to -std=gnu99. If you are worried about supporting very old compilers, then -D_GNU_SOURCE is probably the safest option.
Here is the quote from the CentOS 7 gethostname manual page:
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
gethostname():
Since glibc 2.12: _BSD_SOURCE || _XOPEN_SOURCE >= 500
|| /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200112L
Here is the compiler output before the fix:
gcc -funroll-loops -O3 -ansi -std=c99 -pedantic-errors -Wall -I/usr/include/cfitsio -c main.c
main.c: In function 'main':
main.c:251: error: implicit declaration of function 'gethostname'
main.c:21: warning: unused variable 'scatterksumSubstamps'
main.c:21: warning: unused variable 'meanksumSubstamps'
make: *** [main.o] Error 1
- Missing
#include "globals.h" in extractkern.c
This resulted in the following compiler errors:
gcc -funroll-loops -O3 -ansi -std=gnu99 -pedantic-errors -Wall -I/usr/include/cfitsio -c extractkern.c
extractkern.c: In function 'make_kernel':
extractkern.c:439: error: 'rPixX' undeclared (first use in this function)
extractkern.c:439: error: (Each undeclared identifier is reported only once
extractkern.c:439: error: for each function it appears in.)
extractkern.c:440: error: 'rPixY' undeclared (first use in this function)
make: *** [extractkern.o] Error 1
I added the missing #include after the others in extractkern.c, and the compile completed successfully.
Thanks!
I had trouble building this on CentOS 5-7 (both 32 and 64 bit). There were two separate issues:
gethostname()function was not found inunistd.hThis is caused by a GNU feature macro requirement test. It can be fixed by adding
-D_GNU_SOURCEto the compiler options in theMakefile. Another way to fix it is to change-std=c99to-std=gnu99. If you are worried about supporting very old compilers, then-D_GNU_SOURCEis probably the safest option.Here is the quote from the CentOS 7
gethostnamemanual page:Here is the compiler output before the fix:
#include "globals.h"inextractkern.cThis resulted in the following compiler errors:
I added the missing
#includeafter the others inextractkern.c, and the compile completed successfully.Thanks!