Ubuntu gcc编译安装fcgi出错的解决办法

对于fcgi,我不管是用常规的 2.4.0版本,还是用最新的2.4.1(09年10月份发布的),都是出现如下的错误:

root@localhost:~/downloads/fcgi-2.4.1-SNAP-0910052249# ./configure --prefix=/usr/local/fcgi-2.4.1

这一步没有问题。

接下来

root@localhost:~/downloads/fcgi-2.4.1-SNAP-0910052249# make
make all-recursive
make[1]: Entering directory `/root/downloads/fcgi-2.4.1-SNAP-0910052249'
Making all in libfcgi
make[2]: Entering directory `/root/downloads/fcgi-2.4.1-SNAP-0910052249/libfcgi'
if /bin/bash ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../include -g -O2 -MT fcgio.lo -MD -MP -MF ".deps/fcgio.Tpo" -c -o fcgio.lo fcgio.cpp;
then mv -f ".deps/fcgio.Tpo" ".deps/fcgio.Plo"; else rm -f ".deps/fcgio.Tpo"; exit 1; fi
g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../include -g -O2 -MT fcgio.lo -MD -MP -MF .deps/fcgio.Tpo -c fcgio.cpp -fPIC -DPIC -o .libs/fcgio.o
fcgio.cpp: In destructor 'virtual fcgi_streambuf::~fcgi_streambuf()':
fcgio.cpp:50: error: 'EOF' was not declared in this scope
fcgio.cpp: In member function 'virtual int fcgi_streambuf::overflow(int)':
fcgio.cpp:70: error: 'EOF' was not declared in this scope
fcgio.cpp:75: error: 'EOF' was not declared in this scope
fcgio.cpp: In member function 'virtual int fcgi_streambuf::sync()':
fcgio.cpp:86: error: 'EOF' was not declared in this scope
fcgio.cpp:87: error: 'EOF' was not declared in this scope
fcgio.cpp: In member function 'virtual int fcgi_streambuf::underflow()':
fcgio.cpp:113: error: 'EOF' was not declared in this scope
make[2]: *** [fcgio.lo] Error 1
make[2]: Leaving directory `/root/downloads/fcgi-2.4.1-SNAP-0910052249/libfcgi'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/downloads/fcgi-2.4.1-SNAP-0910052249'
make: *** [all] Error 2
root@localhost:~/downloads/fcgi-2.4.1-SNAP-0910052249#

我的gcc版本如下:

root@localhost:~/downloads/fcgi-2.4.1-SNAP-0910052249/include# gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu8' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8)
root@localhost:~/downloads/fcgi-2.4.1-SNAP-0910052249/include#

我想这个fcgi开发一点也不活跃,而gcc的最新版本不断出来,很有可能是由于这方面引的原因,我又调整了一下关键字

gcc compile fcgi,(之前都是没有方向的搜索)。终于在第一条结果中找到原因了:http://bugs.gentoo.org/256654

--------------------------------------------------------------------

Build of dev-libs/fcgi-2.4.1_pre0311112127 fails with the following errors:

fcgio.cpp: In destructor 'virtual fcgi_streambuf::~fcgi_streambuf()':
fcgio.cpp:50: error: 'EOF' was not declared in this scope
fcgio.cpp: In member function 'virtual int fcgi_streambuf::overflow(int)':
fcgio.cpp:70: error: 'EOF' was not declared in this scope
fcgio.cpp:75: error: 'EOF' was not declared in this scope
fcgio.cpp: In member function 'virtual int fcgi_streambuf::sync()':
fcgio.cpp:86: error: 'EOF' was not declared in this scope
fcgio.cpp:87: error: 'EOF' was not declared in this scope
fcgio.cpp: In member function 'virtual int fcgi_streambuf::underflow()':
fcgio.cpp:113: error: 'EOF' was not declared in this scope

This is because #include <cstdio> is missing from one of the headers.
鉴于此:在解压包include/fcgio.h加入头文件#include<cstdio>,之后,编译将没有问题了。
编译fastcgi:gcc -lfcgi fcgi1.c -o fcgi1.fcgi
参考:http://www.360fire.cn/Java/Tomcat/2010-08-31/5598.html

原文地址:https://www.cnblogs.com/wintergrass/p/2085878.html