Building Node.JS on Solaris: "Use of <stdbool.h> is valid only in a c99 compilation environment."
I am attempting to install Node.JS on Solaris. This is out of the box Solaris 9/10 x86 (September 2010 which is most rec开发者_运维知识库ent) and using only default packages.
The directions I am following are here: https://github.com/joyent/node/wiki/Installation. I am using the latest stable version of Node.JS found on their home page http://nodejs.org
Here is what I have tried...
-bash-3.00# export PATH=$PATH:/usr/sfw/bin:/usr/xpg4/bin
-bash-3.00# ./configure --prefix=/tmp/node
Checking for program g++ or c++ : /usr/sfw/bin/g++
Checking for program cpp : /usr/sfw/bin/cpp
Checking for program ar : /usr/xpg4/bin/ar
Checking for program ranlib : not found
Checking for g++ : ok
Checking for program gcc or cc : /usr/sfw/bin/gcc
Checking for program ar : /usr/xpg4/bin/ar
Checking for program ranlib : not found
Checking for gcc : ok
Checking for library dl : yes
Checking for openssl : yes
Checking for library util : not found
Checking for library rt : yes
Checking for library socket : yes
Checking for library nsl : yes
--- libeio ---
Checking for library pthread : yes
Checking for function pthread_create : yes
Checking for function pthread_atfork : yes
Checking for futimes(2) : no
Checking for readahead(2) : no
Checking for fdatasync(2) : no
Checking for pread(2) and pwrite(2) : yes
Checking for sendfile(2) : no
Checking for sync_file_range(2) : no
--- libev ---
Checking for header sys/inotify.h : not found
Checking for header sys/epoll.h : not found
Checking for header port.h : yes
Checking for function port_create : yes
Checking for header poll.h : yes
Checking for function poll : yes
Checking for header sys/event.h : not found
Checking for header sys/queue.h : yes
Checking for function kqueue : not found
Checking for header sys/select.h : yes
Checking for function select : yes
Checking for header sys/eventfd.h : not found
Checking for SYS_clock_gettime : no
Checking for library rt : yes
Checking for function clock_gettime : yes
Checking for function nanosleep : yes
Checking for function ceil : yes
Checking for fdatasync(2) with c++ : no
'configure' finished successfully (1.936s)
-bash-3.00# make
Waf: Entering directory `/tmp/node-v0.4.3/build'
DEST_OS: sunos
DEST_CPU: ia32
Parallel Jobs: 1
Product type: program
[ 3/75] cc: deps/c-ares/ares_strcasecmp.c -> build/default/deps/c-ares/ares_strcasecmp_1.o
/usr/sfw/bin/gcc -D_GNU_SOURCE -DHAVE_CONFIG_H=1 -threads -m32 -g -O3 -DHAVE_OPENSSL=1 -DEV_FORK_ENABLE=0 -DEV_EMBED_ENABLE=0 -DEV_MULTIPLICITY=0 -DX_STACKSIZE=65536 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DEV_MULTIPLICITY=0 -DHAVE_FDATASYNC=0 -DPLATFORM="sunos" -D__POSIX__=1 -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -DNDEBUG -Idefault/deps/c-ares -I../deps/c-ares -Idefault/deps/c-ares/sunos-ia32 -I../deps/c-ares/sunos-ia32 ../deps/c-ares/ares_strcasecmp.c -c -o default/deps/c-ares/ares_strcasecmp_1.o
In file included from ../deps/c-ares/setup_once.h:73,
from ../deps/c-ares/sunos-ia32/ares_setup.h:195,
from ../deps/c-ares/ares_strcasecmp.c:18:
/usr/include/stdbool.h:42:2: #error "Use of <stdbool.h> is valid only in a c99 compilation environment."
Waf: Leaving directory `/tmp/node-v0.4.3/build'
Build failed: -> task failed (err #1):
{task: cc ares_strcasecmp.c -> ares_strcasecmp_1.o}
*** Error code 1
The following command caused the error:
python tools/waf-light --product-type=program build
make: Fatal error: Command failed for target `program'
-bash-3.00#
I think the key error is
/usr/include/stdbool.h:42:2: #error "Use of <stdbool.h> is valid only in a c99 compilation environment."
which I can recreate like this
-bash-3.00# cd build
-bash-3.00# /usr/sfw/bin/gcc -D_GNU_SOURCE -DHAVE_CONFIG_H=1 -threads -m32 -g -O3 -DHAVE_OPENSSL=1 -DEV_FORK_ENABLE=0 -DEV_EMBED_ENABLE=0 -DEV_MULTIPLICITY=0 -DX_STACKSIZE=65536 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DEV_MULTIPLICITY=0 -DHAVE_FDATASYNC=0 -DPLATFORM="sunos" -D__POSIX__=1 -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -DNDEBUG -Idefault/deps/c-ares -I../deps/c-ares -Idefault/deps/c-ares/sunos-ia32 -I../deps/c-ares/sunos-ia32 ../deps/c-ares/ares_strcasecmp.c -c -o default/deps/c-ares/ares_strcasecmp_1.o
In file included from ../deps/c-ares/setup_once.h:73,
from ../deps/c-ares/sunos-ia32/ares_setup.h:195,
from ../deps/c-ares/ares_strcasecmp.c:18:
/usr/include/stdbool.h:42:2: #error "Use of <stdbool.h> is valid only in a c99 compilation environment."
-bash-3.00# cd ..
-bash-3.00#
Any ideas? Do I need to specify a different option to use C99 or to not use C99?
Again, this is out of the box Solaris 9/10 on x86. I have not done anything that would change any of the compilers or for that matter any other stuff that is installed by default.
Try adding -std=c99
or -std=gnu99
to your CFLAGS
before invoking ./configure
, like so:
CFLAGS=-std=c99 ./configure --prefix=/tmp/node
This error means that Node.JS is probably using AC_PROG_CC
in its configure.ac
script when it should be using AC_PROG_CC_C99
, see the page on C compiler detection on autoconf's manual. You should report this bug to the Node.JS developers, and test that the proper solution works on your system.
I got past this error by doing:
CC=/path/to/solaris_32/bin/gcc (and then the make command I was trying to run)
This way it knew to use gcc and not /usr/bin/cc which was throwing the error.
精彩评论