[collectd] Compiling collectd-4.6.2 / collectd-git-repo on Solaris 10 Update 6
Peter Bray
pdb_ml at yahoo.com.au
Sun May 10 12:30:11 CEST 2009
Greetings,
I have been trying to compile collectd-4.6.2 on Solaris 10 Update 6 (also known as Solaris 10 10/2008) on both SPARC and x86 (AMD64), with both gcc-4.1.2 and Sun Studio 12. I received the following #error from the compilation process:
#error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications require the use of c99"
A full example is included at the end of this email. The Sun Studio 12 compiler generates the same error but of course from /usr/include/sys/feature_tests.h (c.f. its GCC counterpart listed below)
In 4.6.2, this error occurs for src/libcollectdclient/client.c, src/bind.c, src/target_notification.c, src/target_replace.c, src/target_set.c, src/collectd-nagios.c, src/collectd-nagios.c, src/filter_chain.c, src/meta_data.c while in the current git-repo the error only occurs in src/bind.c. Because one error is easier to fix then many and with the pending release of a new version, I looked into the git-repo build issue with src/bind.c.
Looking src/bind.c and the error I decided to comment out:
#define _XOPEN_SOURCE 600 /* glibc2 needs this for strptime */
The build (from git-repo) now works fine and the collectd seem functional (full configuration and testing pending). Looking again at 4.6.2 again, the list of files that don't compile and those contain _XOPEN_SOURCE we have a nearly perfect correspondence:
% find . -type f | xargs grep _XOPEN_SOURCE
./src/bind.c:#ifndef _XOPEN_SOURCE
./src/bind.c:# define _XOPEN_SOURCE 600
./src/target_notification.c:#ifdef _XOPEN_SOURCE
./src/target_notification.c:# undef _XOPEN_SOURCE
./src/target_notification.c:#define _XOPEN_SOURCE 500
./src/target_replace.c:#ifdef _XOPEN_SOURCE
./src/target_replace.c:# undef _XOPEN_SOURCE
./src/target_replace.c:#define _XOPEN_SOURCE 500
./src/target_set.c:#ifdef _XOPEN_SOURCE
./src/target_set.c:# undef _XOPEN_SOURCE
./src/target_set.c:#define _XOPEN_SOURCE 500
./src/filter_chain.c:#ifdef _XOPEN_SOURCE
./src/filter_chain.c:# undef _XOPEN_SOURCE
./src/filter_chain.c:#define _XOPEN_SOURCE 500
./src/meta_data.c:#ifdef _XOPEN_SOURCE
./src/meta_data.c:# undef _XOPEN_SOURCE
./src/meta_data.c:#define _XOPEN_SOURCE 500
I would suggest that _XPOEN_SOURCE definition in bind.c be made conditional, but I not sure of the best approach to this issue. It should be noted that this is the last .c file containing a reference to _XOPEN_SOURCE, so maybe the solution used to remove the other instances would be appropriate here.
I hope this helps others looking at collectd on Solaris.
Regards,
Peter Bray
Sydney, Australia
gmake[4]: Entering directory `/tmp/64-bit/collectd-4.6.2/src/libcollectdclient'
/bin/bash ../../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../src -D_POSIX_PTHREAD_SEMANTICS -Wall -Werror -g -O2 -c -o client.lo client.c
gcc -DHAVE_CONFIG_H -I. -I../../src -D_POSIX_PTHREAD_SEMANTICS -Wall -Werror -g -O2 -c client.c -fPIC -DPIC -o .libs/client.o
In file included from /usr/include/iso/stdlib_iso.h:30,
from /usr/include/stdlib.h:18,
from client.c:57:
/pkgs/64-bit/release/gcc-4.1.2/lib/gcc/i386-pc-solaris2.10/4.1.2/include/sys/feature_tests.h:345:2: error: #error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications require the use of c99"
gmake[4]: *** [client.lo] Error 1
More information about the collectd
mailing list