程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> PHP綜合 >> Windows下編譯PHP5.4和xdebug全記錄

Windows下編譯PHP5.4和xdebug全記錄

編輯:PHP綜合

實際上我最終目的是編譯得到支持 PHP5.4 的 php_xdebug.dll,而在此之前,成功編譯 PHP5.4 是必須的。

編譯環境以及相關軟件包:
1.Microsoft Visual C++ 2008 Express Edition with SP1
2.Windows SDK 6.1
3.PHP SDK Binary Tools
4.Dependable libs
5.PHP5.4 Sources
6.Xdebug 2.2.0-dev
如果你需要的是 VC6 的編譯環境,那麼你需要安裝 Visual C++ 6.0,而 SDK 則需要換成:
Windows Server 2003 PSDK

編譯過程:

准備好咖啡、可樂,做好准備,可能要折騰數小時…

安裝 VC++ 2008 以及 Windows SDK 6.1

建立如下目錄:
復制代碼 代碼如下:
D:\php-sdk
D:\php-sdk\php54dev
D:\php-sdk\pecl

解壓 php-sdk-binary-tools-20110915.zip 中的所有文件至 D:\php-sdk
提取 deps-5.4-vc9-x86.7z 中的 deps 目錄至 D:\php-sdk\php54dev
解壓 php5.4 源碼至 D:\php-sdk\php54dev,目錄名任取,比如 php-5.4.0RC3
xdebug 的源碼放到 D:\php-sdk\pecl\xdebug

最終的目錄結構大概是這樣子的:
復制代碼 代碼如下:
D:\php-sdk>tree D:\php-sdk
Folder PATH listing for volume DISK_VOL2
Volume serial number is 0C74-AD73
D:\PHP-SDK
├───bin
├───php54dev
│   ├───deps
│   │   ├───bin
│   │   ├───include
│   │   ├───lib
│   │   └───sybase
│   ├───pecl
│   │   └───xdebug
│   └───php-5.4.0RC3
├───script
└───share

打開 Windows SDK CMD Shell,執行:setenv /x86 /xp /release,如果你是64位系統,那麼這個命令是必須的,不要試圖把參數改成 /x64,否則後續的 make 階段,你會看到成千上萬條 WARNING …

設定 PATH:set PATH=D:\php-sdk\bin;%PATH%

切換 SHELL 目錄至 D:\php-sdk\php54dev\php-5.4.0RC3>,執行 buildconf 生成 configure 腳本:
復制代碼 代碼如下:
D:\php-sdk\php54dev\php-5.4.0RC3>buildconf
Rebuilding configure.js
Now run 'configure --help'
D:\php-sdk\php54dev\php-5.4.0RC3>

執行 configure 生成 Make 腳本,可以查看 configure –help 以獲取更多編譯選項:
復制代碼 代碼如下:
D:\php-sdk\php54dev\php-5.4.0RC3>configure --disable-snapshot-build --disable-debug-pack --disable-ipv6 --disable-zts --disable-isapi --disable-nsapi --without-t1lib --without-mssql --without-pdo-mssql --without-pi3web --without-enchant --enable-com-dotnet --with-mcrypt=static --disable-static-analyze --with-xdebug=shared

這裡我使用了 –disable-snapshot-build 關掉了 snapshot 模式,因為這個命令會強制開啟許多對我來說無用的選項,比如 aolserver,apache sapi 之類的,最後我加上了 –with-xdebug=shared,在使用這個選項之前最好確認 xdebug 源碼的位置正確,如果沒什麼問題的話,buildconf 之後,在 configure –help 中你可以看到這個選項,shared 表示編譯成動態鏈接庫。

如果你要編譯其它的 pecl 擴展(比如 apc,bcompiler 等),只需要相關的源碼下載放到 pecl 目錄,重新執行 buildconf 即可。

若 configure 無問題,最後執行 nmake 開始編譯過程,Good Luck! :)

最後一步 nmake snap,組織所有編譯好的文件的目錄結構(也就是你平時下載的 PHP 二進制包的結構),並用 zip 打包。

最終生成的文件位置:D:\php-sdk\php54dev\php-5.4.0RC3\Release(_TS)

錯誤處理:
nmake 過程中會產生很多的 Warning,只要不中斷,那麼就無視好了。

關於 calendar.c 和 jewish.c 的編碼問題:
復制代碼 代碼如下:
ext\calendar\calendar.c : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
dow.c
easter.c
french.c
gregor.c
jewish.c
ext\calendar\jewish.c : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
ext\calendar\jewish.c(324) : error C2001: newline in constant
ext\calendar\jewish.c(325) : error C2001: newline in constant
ext\calendar\jewish.c(326) : error C2001: newline in constant
ext\calendar\jewish.c(327) : error C2001: newline in constant
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\cl.exe"' : return code '0x2'
Stop.

這兩個文件使用的是 ANSI 編碼,包含有一些西文的特殊字符,GBK 字符集中不存在。
可用 editplus 打開,編碼選擇:West European (Windows),另存為 UTF-8。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved