PHP模块编译无法辨识问题
1.问题描述 编译PHP模块iconv cd /root/php-5.2.6/ext/iconv 执行phpize...
扫描右侧二维码阅读全文
17
2008/10

PHP模块编译无法辨识问题

1.问题描述
编译PHP模块iconv
cd /root/php-5.2.6/ext/iconv
执行phpize
/root/php/bin/phpize
检查./configure选项
./configure --help
`configure' configures this package to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..']

Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--datadir=DIR read-only architecture-independent data [PREFIX/share]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--infodir=DIR info documentation [PREFIX/info]
--mandir=DIR man documentation [PREFIX/man]

System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
--target=TARGET configure for building compilers for TARGET [HOST]

Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-shared=PKGS build shared libraries default=yes
--enable-static=PKGS build static libraries default=yes
--enable-fast-install=PKGS optimize for fast installation default=yes
--disable-libtool-lock avoid locking (might break parallel builds)

Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-libdir=NAME Look for libraries in .../NAME rather than .../lib
--with-php-config=PATH Path to php-config php-config
--without-iconv=DIR Exclude iconv support
--with-gnu-ld assume the C compiler uses GNU ld default=no
--with-pic try to use only PIC/non-PIC objects default=use both
--with-tags=TAGS include additional configurations automatic

Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L if you have libraries in a
nonstandard directory
CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have
headers in a nonstandard directory
CPP C preprocessor
CXXCPP C++ preprocessor

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
发现并没有--with-iconv或者--enable-iconv选项
那么就是用默认配置
./configure --with-php-config=/root/php/bin/php-config
make && make install
编译出模块后加载到php.ini
然后执行php程序出错
Warning: PHP Startup: Invalid library (maybe not a PHP library) 'iconv.so' in Unknown on line 0
报错显示iconv.so不是一个可用的动态链接库
2.解决方法
使用命令检查iconv.so
nm iconv.so | grep get_module
返回确实为空
发现配置参数都是OK的.其他一些选项都是默认的yes
想起来编译PHP如果加上iconv,需要加上--with-iconv
而一般的php模块都会需要加上--enable-模块名的参数
尝试
./configure --with-iconv --with-php-config=/root/php/bin/php-config
make &&make install
编译后再尝试
模块正常加载
看来文档和实际不同
确实真的是很大的问题.要不是php编译里面有这个参数,而我想起来试试看的话
可能一直都无法解决这个问题.至少也是要通过阅读./configure以及make才能知道了.

Last modification:November 26th, 2018 at 04:16 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment