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

來源:互聯網
上載者:User

實際上我最終目的是編譯得到支援 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。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.