找大发欢乐生肖-大发欢乐生肖彩票首页 - 技术文章

Windows下编译php5.2.17的编译

更新日期:2014-09-27 11:25:44

下载PHP大发欢乐生肖-大发欢乐生肖彩票
http://www.php.net/downloads.php
下载PHP 5.2.12 (tar.bz2)

先下载2个必要的包

http://www.php.net/extra/bindlib_w32.zip
http://www.php.net/extra/win32build.zip

把这2个包的内容放一起
例如PHP大发欢乐生肖-大发欢乐生肖彩票我解压缩到D:\php-5.2.12
这2个压缩包我都解压缩到D:\win32build

用到的zlib:http://www.zlib.net/
用到的libiconv:http://gnuwin32.sourceforge.net/packages/libiconv.htm

命令行进入PHP目录,先执行"C:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT"
设置VC6环境变量,然后执行buildconf.bat

提示:
Rebuilding configure.js
Now run 'cscript /nologo configure.js --help'

接下来要临时设置一下环境变量,不然会提示找不到bison.exe:
Checking for bison.exe ... <not found>
ERROR: bison is required

命令行输入:set path=%path%;D:\win32build\bin
执行:cscript /nologo configure.js --with-php-build="../win32build" --without-libxml --disable-odbc
出现这段就可以继续了:
Creating build dirs...
Generating files...
Generating Makefile
Generating main/internal_functions.c
Generating main/config.w32.h
Done.

Type 'nmake' to build PHP

输入nmake

没有加--without-libxml的话会报错:
.\ext\dom/php_dom.h(33) : fatal error C1083: Cannot open include file: 'libxml/p
arser.h': No such file or directory
NMAKE : fatal error U1077: '"cl.exe"' : return code '0x2'
Stop.

不加--disable-odbc会报如下错误:
ext\odbc\php_odbc_includes.h(237) : error C2061: syntax error : identifier 'SQLL
EN'
........
ext\odbc\php_odbc.c(789) : error C2065: 'len' : undeclared identifier
ext\odbc\php_odbc.c(789) : fatal error C1003: error count exceeds 100; stopping
compilation
NMAKE : fatal error U1077: '"cl.exe"' : return code '0x2'
Stop.

缺少lib会报连接错误:
php5ts.dll.def : error LNK2001: unresolved external symbol _libiconv_version
php5ts.dll.def : error LNK2001: unresolved external symbol compressBound
php5ts.dll.def : error LNK2001: unresolved external symbol deflateBound
php5ts.dll.def : error LNK2001: unresolved external symbol deflatePrime
php5ts.dll.def : error LNK2001: unresolved external symbol gzclearerr
php5ts.dll.def : error LNK2001: unresolved external symbol gzungetc
php5ts.dll.def : error LNK2001: unresolved external symbol inflateBack
php5ts.dll.def : error LNK2001: unresolved external symbol inflateBackEnd
php5ts.dll.def : error LNK2001: unresolved external symbol inflateBackInit_
php5ts.dll.def : error LNK2001: unresolved external symbol inflateCopy
php5ts.dll.def : error LNK2001: unresolved external symbol libiconv
php5ts.dll.def : error LNK2001: unresolved external symbol libiconv_close
php5ts.dll.def : error LNK2001: unresolved external symbol libiconv_open
php5ts.dll.def : error LNK2001: unresolved external symbol libiconv_set_relocati

其中这5条是libiconv的:
php5ts.dll.def : error LNK2001: unresolved external symbol _libiconv_version
php5ts.dll.def : error LNK2001: unresolved external symbol libiconv
php5ts.dll.def : error LNK2001: unresolved external symbol libiconv_close
php5ts.dll.def : error LNK2001: unresolved external symbol libiconv_open
php5ts.dll.def : error LNK2001: unresolved external symbol libiconv_set_relocati
on_prefix

不出意外,到这里PHP就编译完成了。