Windows下編譯PHP5.4和xdebug全記錄
實際上我最終目的是編譯得到支持 PHP5.4 的 php_xdebug.dll,而在此之前,成功編譯 PHP5.4 是必須的。
編譯環(huán)境以及相關(guān)軟件包:
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 的編譯環(huán)境,那么你需要安裝 Visual C++ 6.0,而 SDK 則需要換成:
Windows Server 2003 PSDK
編譯過程:
準備好咖啡、可樂,做好準備,可能要折騰數(shù)小時…
安裝 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
最終的目錄結(jié)構(gòu)大概是這樣子的:
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,執(zhí)行:setenv /x86 /xp /release,如果你是64位系統(tǒng),那么這個命令是必須的,不要試圖把參數(shù)改成 /x64,否則后續(xù)的 make 階段,你會看到成千上萬條 WARNING …
設(shè)定 PATH:set PATH=D:\php-sdk\bin;%PATH%
切換 SHELL 目錄至 D:\php-sdk\php54dev\php-5.4.0RC3>,執(zhí)行 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>
執(zhí)行 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 關(guān)掉了 snapshot 模式,因為這個命令會強制開啟許多對我來說無用的選項,比如 aolserver,apache sapi 之類的,最后我加上了 –with-xdebug=shared,在使用這個選項之前最好確認 xdebug 源碼的位置正確,如果沒什么問題的話,buildconf 之后,在 configure –help 中你可以看到這個選項,shared 表示編譯成動態(tài)鏈接庫。
如果你要編譯其它的 pecl 擴展(比如 apc,bcompiler 等),只需要相關(guān)的源碼下載放到 pecl 目錄,重新執(zhí)行 buildconf 即可。
若 configure 無問題,最后執(zhí)行 nmake 開始編譯過程,Good Luck! :)
最后一步 nmake snap,組織所有編譯好的文件的目錄結(jié)構(gòu)(也就是你平時下載的 PHP 二進制包的結(jié)構(gòu)),并用 zip 打包。
最終生成的文件位置:D:\php-sdk\php54dev\php-5.4.0RC3\Release(_TS)
錯誤處理:
nmake 過程中會產(chǎn)生很多的 Warning,只要不中斷,那么就無視好了。
關(guān)于 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。
- 如何把php5.3版本升級到php5.4或者php5.5
- php5.4以上版本GBK編碼下htmlspecialchars輸出為空問題解決方法匯總
- php5.4以下版本json不支持不轉(zhuǎn)義內(nèi)容中文的解決方法
- 注意:php5.4刪除了session_unregister函數(shù)
- 安裝apache2.2.22配置php5.4(具體操作步驟)
- PHP5.4中json_encode中文轉(zhuǎn)碼的變化小結(jié)
- php 升級到 5.3+ 后出現(xiàn)的一些錯誤,如 ereg(); ereg_replace(); 函數(shù)報錯
- 探尋PHP腳本不報錯的原因
- PHP empty函數(shù)報錯解決辦法
- php 啟動時報錯的簡單解決方法
- php 啟動報錯如何解決
- php5.4傳引用時報錯問題分析
相關(guān)文章
Drupal 添加模塊出現(xiàn)莫名其妙的錯誤的解決方法(往往出現(xiàn)在模塊較多時)
今天用學(xué)習(xí)用Drupal,在同時安裝ctools,CCK,views,panels時出現(xiàn)了奇怪的狀況。2011-04-04PHPCrawl爬蟲庫實現(xiàn)抓取酷狗歌單的方法示例
這篇文章主要介紹了PHPCrawl爬蟲庫實現(xiàn)抓取酷狗歌單的方法,涉及PHPCrawl爬蟲庫的使用及正則匹配相關(guān)操作技巧,需要的朋友可以參考下2017-12-12PHP網(wǎng)站基礎(chǔ)優(yōu)化方法小結(jié)
以下這些基礎(chǔ)技巧可以讓你的PHP網(wǎng)站運行得更快一些。2008-09-09PHP+MySql+jQuery實現(xiàn)的"頂"和"踩"投票功能
這篇文章主要為大家詳細介紹了PHP+MySql+jQuery實現(xiàn)的"頂"和"踩"投票功能,具有一定的參考價值,感興趣的朋友可以參考一下2016-05-05