php windows 編譯

Post date: 2013/1/24 上午 08:55:05

php-5.2.2 windows 編譯

使用的是visual studio 2005 沒有使用 cgwin

編譯後的目標編譯到e:\php目錄下

你需要先下載prebuild,

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

解壓縮到E:\win32build,

將E:\win32build\bin目錄下的bison.exe flex.exe複製到系統的c:\windows下面

下載php 5.2.2 的 source

http://www.php.net/get/php-5.2.2.tar.bz2/from/a/mirror

解壓

進入vs2005命令提示行 cd 到E:\pfs\php-5.2.2.tar\php-5.2.2

E:\pfs\php-5.2.2.tar\php-5.2.2>

E:\pfs\php-5.2.2.tar\php-5.2.2>buildconf

Rebuilding configure.js

Now run 'cscript /nologo configure.js --help'

提示你運行cscript /nologo configure.js --help 查看幫助

這裡已經有一個build 成功的命令複製運行他

cscript /nologo configure.js "--with-php-build=E:\win32build" "--enable-object-out-dir=e:\php" "--without-libxml" "--disable-xmlwriter" "--without-xml" "--without-simplexml" "--without-dom" "--without-libxml" "--disable-zlib" "--disable-tokenizer" "--disable-calendar" "--disable-com-dotnet" "--disable-ctype"

輸入

E:\pfs\php-5.2.2.tar\php-5.2.2>cscript /nologo configure.js "--with-php-build=E

:\win32build" "--enable-object-out-dir=e:\php" "--without-libxml" "--disable-xml

writer" "--without-xml" "--without-simplexml" "--without-dom" "--without-libxml"

"--disable-zlib" "--disable-tokenizer" "--disable-calendar" "--disable-com-dotn

et" "--disable-ctype"

提示

Type 'nmake' to build PHP

輸入

E:\pfs\php-5.2.2.tar\php-5.2.2>nmake

SAPI sapi\cli build complete

編譯完畢:

在E:\php\Release_TS能看到

E:\php>cd E:\php\Release_TS

E:\php\Release_TS>php -v

PHP 5.2.2 (cli) (built: May 22 2007 11:23:15)

Copyright (c) 1997-2007 The PHP Group

Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

看到built: May 22 2007 11:23:15 ,是的就是剛才.

使用是visual studio 2005編譯 ,分發到別的機器上面,需要msvcr80.dll等

C:\Program Files\Microsoft Visual Studio 8\VC\redist\x86\Microsoft.VC80.CRT有

php5ts.dll 4589k(5.2.2發行版)

php5ts.dll 2732k(編譯完成後的)

這個編譯出來的很多擴展都--without.

編譯花了3分多鐘,感覺用了20幾分鐘似的,cpu一直100%

還有就是幾個lib編譯特別花時間,就像停止了一樣.

configure 的時候,以為能像unix 下面的用 --disable-all呢,

結果發現生成Makefile的有問題,Makefile改了半天也沒有弄好,

還是一個一個的disable,without.

直到到上面那個cscript /nologo configure.js

花了336 MB產生obj,和lib文件

沒有firefox的g級別厲害.

使用vs 6和vs 2005的方法一樣.

測試通過winxp2,vs6,vs2005,php-5.2.2

擴展php,extension 例子幾天後上出來.

Saving configure options to config.nice.bat

Checking for cl.exe ... <in default path>

Checking for cl.exe ... <in default path>

Detected MS compiler version 14

Detected 32-bit compiler

Checking for link.exe ... C:\Program Files\Microsoft Visual Studio 8\VC\BIN

Checking for nmake.exe ... <in default path>

Checking for lib.exe ... <in default path>

Checking for bison.exe ... <not found>

ERROR: bison is required

缺少bison解決辦法

將E:\win32build\bin目錄下的bison.exe flex.exe複製到系統的c:\windows下面

rc /fo e:\php\Release_TS\php5ts.dll.res /d FILE_DESCRIPTION="\"PHP Scrip

t Interpreter\"" /d FILE_NAME="\"php5ts.dll\"" /d PRODUCT_NAME="\"PHP Script In

terpreter\"" /Ie:\php\Release_TS /d MC_INCLUDE="\"e:\php\Release_TS\wsyslog.rc\

"" win32\build\template.rc

正在創建庫 e:\php\Release_TS\php5ts.lib 和對像 e:\php\Release_TS\php5ts.exp

rc /fo e:\php\Release_TS\php-cgi.exe.res /D WANT_LOGO /d FILE_DESCRIPTI

ON="\"CGI / FastCGI\"" /d FILE_NAME="\"php-cgi.exe\"" /d PRODUCT_NAME="\"PHP php

-cgi.exe\"" /d THANKS_GUYS="\"Thanks to Rasmus Lerdorf, Stig Bakken, Shane Carav

eo, Dmitry Stogov\"" win32\build\template.rc

SAPI sapi\cgi build complete

getopt.c

php_cli.c

C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\ws2tcpip.h(593

) : warning C4142: benign redefinition of type

php_cli_readline.c

rc /fo e:\php\Release_TS\php.exe.res /D WANT_LOGO /d FILE_DESCRIPTION="

\"CLI\"" /d FILE_NAME="\"php.exe\"" /d PRODUCT_NAME="\"PHP php.exe\"" /d THANKS_

GUYS="\"Thanks to Edin Kadribasic, Marcus Boerger, Johannes Schlueter\"" win32\b

uild\template.rc

SAPI sapi\cli build complete