acbecker / hotpants

hotpants
MIT License
43 stars 23 forks source link

Build issues on CentOS 5-7 #1

Open irasnyd opened 9 years ago

irasnyd commented 9 years ago

I had trouble building this on CentOS 5-7 (both 32 and 64 bit). There were two separate issues:

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

2) 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!

acbecker commented 9 years ago

Thanks! Please feel free to put in a pull request and we can merge this to master. Andy