Windows下編譯PHP5.4和xdebug全記錄
實(shí)際上我最終目的是編譯得到支持 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
編譯過程:
準(zhǔn)備好咖啡、可樂,做好準(zhǔn)備,可能要折騰數(shù)小時(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),那么這個(gè)命令是必須的,不要試圖把參數(shù)改成 /x64,否則后續(xù)的 make 階段,你會(huì)看到成千上萬條 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 以獲取更多編譯選項(xiàng):
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 模式,因?yàn)檫@個(gè)命令會(huì)強(qiáng)制開啟許多對(duì)我來說無用的選項(xiàng),比如 aolserver,apache sapi 之類的,最后我加上了 –with-xdebug=shared,在使用這個(gè)選項(xiàng)之前最好確認(rèn) xdebug 源碼的位置正確,如果沒什么問題的話,buildconf 之后,在 configure –help 中你可以看到這個(gè)選項(xiàng),shared 表示編譯成動(dòng)態(tài)鏈接庫(kù)。
如果你要編譯其它的 pecl 擴(kuò)展(比如 apc,bcompiler 等),只需要相關(guān)的源碼下載放到 pecl 目錄,重新執(zhí)行 buildconf 即可。
若 configure 無問題,最后執(zhí)行 nmake 開始編譯過程,Good Luck! :)
最后一步 nmake snap,組織所有編譯好的文件的目錄結(jié)構(gòu)(也就是你平時(shí)下載的 PHP 二進(jìn)制包的結(jié)構(gòu)),并用 zip 打包。
最終生成的文件位置:D:\php-sdk\php54dev\php-5.4.0RC3\Release(_TS)
錯(cuò)誤處理:
nmake 過程中會(huì)產(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.
這兩個(gè)文件使用的是 ANSI 編碼,包含有一些西文的特殊字符,GBK 字符集中不存在。
可用 editplus 打開,編碼選擇:West European (Windows),另存為 UTF-8。
- 如何把php5.3版本升級(jí)到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 升級(jí)到 5.3+ 后出現(xiàn)的一些錯(cuò)誤,如 ereg(); ereg_replace(); 函數(shù)報(bào)錯(cuò)
- 探尋PHP腳本不報(bào)錯(cuò)的原因
- PHP empty函數(shù)報(bào)錯(cuò)解決辦法
- php 啟動(dòng)時(shí)報(bào)錯(cuò)的簡(jiǎn)單解決方法
- php 啟動(dòng)報(bào)錯(cuò)如何解決
- php5.4傳引用時(shí)報(bào)錯(cuò)問題分析
相關(guān)文章
Drupal 添加模塊出現(xiàn)莫名其妙的錯(cuò)誤的解決方法(往往出現(xiàn)在模塊較多時(shí))
今天用學(xué)習(xí)用Drupal,在同時(shí)安裝ctools,CCK,views,panels時(shí)出現(xiàn)了奇怪的狀況。2011-04-04PHPCrawl爬蟲庫(kù)實(shí)現(xiàn)抓取酷狗歌單的方法示例
這篇文章主要介紹了PHPCrawl爬蟲庫(kù)實(shí)現(xiàn)抓取酷狗歌單的方法,涉及PHPCrawl爬蟲庫(kù)的使用及正則匹配相關(guān)操作技巧,需要的朋友可以參考下2017-12-12PHP網(wǎng)站基礎(chǔ)優(yōu)化方法小結(jié)
以下這些基礎(chǔ)技巧可以讓你的PHP網(wǎng)站運(yùn)行得更快一些。2008-09-09PHP+MySql+jQuery實(shí)現(xiàn)的"頂"和"踩"投票功能
這篇文章主要為大家詳細(xì)介紹了PHP+MySql+jQuery實(shí)現(xiàn)的"頂"和"踩"投票功能,具有一定的參考價(jià)值,感興趣的朋友可以參考一下2016-05-05