PostgreSQL修炼之道:从小工到专家(第2版)
上QQ阅读APP看书,第一时间看更新

2.2.8 编译安装过程中的常见问题及解决方法

问题一:运行“./configure”时报“error:zlib library not found”错误是怎么回事?示例如下:


osdba@ubuntu01:~/src/postgresql-12.2$ ./configure --prefix=/usr/local/pgsql12.2 --with-perl --with-python
checking build system type... x86_64-unknown-linux-gnu
....
....
checking for inflate in -lz... no
configure: error: zlib library not found
If you have zlib already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.

答:这是没有安装zlib开发包的缘故,请安装zlib开发包。

问题二:我已安装了libreadline6安装包,但运行“./configure”时仍报“error:readline library not found”错误是怎么回事?示例如下:


osdba@ubuntu01:~/src/postgresql-12.2$ ./configure --prefix=/usr/local/pgsql12.2 --with-perl --with-python
checking build system type... x86_64-unknown-linux-gnu
...
...
checking for library containing readline... no
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.

答:包安装错误,需要安装开发包,即安装libreadline6-dev开发包,而不是libreadline6安装包。

问题三:在运行“./configure”时报以下警告,是否会导致编译出来的PostgreSQL功能缺失?示例如下:


checking for bison... no
configure: WARNING:
*** Without Bison you will not be able to build PostgreSQL from Git nor
*** change any of the parser definition files.  You can obtain Bison from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this, because the Bison
*** output is pre-generated.)
checking for flex... no
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from Git nor
*** change any of the scanner definition files.  You can obtain Flex from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)

答:不会影响编译出来的PostgreSQL的功能。该警告的意思是说没有Bison和Flex工具,因此无法使用Git方式编译。这里未使用Git,所以没有影响。Bison是自动生成语法分析器的程序,Flex则是自动生成词法分析器的程序,在PostgreSQL中主要用于SQL的词法解析和语法解析。因为源码包中已经生成了词法解析和语法解析的C源代码,所以没有Bison和Flex也可以正常编译。当然也可以安装Bison和Flex这两个工具,命令如下:


sudo aptitude install bison flex

问题四:在运行make时报“cannot find -lperl”错误,示例如下:


gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fpic -shared -o plperl.so plperl.o SPI.o Util.o -L../../../src/port -Wl,--as-needed -Wl,-rpath,'/usr/lib/perl/5.14/CORE',--enable-new-dtags  -fstack-protector -L/usr/local/lib  -L/usr/lib/perl/5.14/CORE -lperl -ldl -lm -lpthread -lc -lcrypt 
/usr/bin/ld: cannot find -lperl
collect2: error: ld returned 1 exit status
make[3]: *** [plperl.so] Error 1
make[3]: Leaving directory `/home/osdba/src/postgresql-9.2.3/src/pl/plperl'
make[2]: *** [all-plperl-recurse] Error 2
make[2]: Leaving directory `/home/osdba/src/postgresql-9.2.3/src/pl'
make[1]: *** [all-pl-recurse] Error 2
make[1]: Leaving directory `/home/osdba/src/postgresql-9.2.3/src'
make: *** [all-src-recurse] Error 2

答:这是因为在运行“./configure”时加了--with-perl但未安装perl开发包。注意,未安装perl开发包在运行“./configure”时并不报错,而make的时候会报错。在Debian或Ubuntu下,只需安装libperl-dev包即可:


sudo aptitude install libperl-dev