在Windows下編譯安裝AMFEXT for PHP5.3
AMFEXT官方未提供PHP5.3版的dll檔案,不得不自己動手編譯,以下是編譯小記:
1. 下載必要的軟體.
1). PHP5.3 for Win32二進位和原始碼各一份
2). VC6或以上IDE
3). Cygwin.
4). 兩個必要的包
http://www.php.net/extra/bindlib_w32.zip
http://www.php.net/extra/win32build.zip
5). 下載amfext 0.9.2-dev版
2. 解壓縮軟體到適當目錄
1). 解壓縮php二進位代碼到e:\php5.3.6目錄(其實我們只感興趣dev子目錄下的php5ts.lib檔案)
2). 解壓縮php原始碼到e:\php5.3.6-sources目錄
3). 解壓縮amfext 0.9.2到e:\php5.3.6-sources\ext\amfext目錄下
4). 解壓縮bindlib_w32.zip和win32build.zip到同樣目錄(如:c:\win32build)
設定路徑set path=%path%;c:\win32build\bin
3. 編譯amfext VC工程
1). 開啟amfext.dsp工程檔案
2). 設定工程
Project->Settings(Win32 Release)->Link 為:e:\php5.3.6\dev\php5ts.lib
Build->Set Active Project Configuration選中amftext - Win32 Release.
3). 編譯amfext
由於amfext for php5.3有個bug,所以編譯之前要修改amf.c
//On line 1188, replace: int deallocResult = (*struc)->refcount; //with int deallocResult = Z_REFCOUNT_PP(struc); //On line 2674, replace: newval->refcount--; //with Z_DELREF_P(newval);
現在按F7編譯工程,提示
Cannot open include file: '../main/config.w32.h',提示找不到檔案,到php原始碼的字母main目錄下一看,果然沒有這個檔案,要自己產生這個檔案:
步驟1. 到PHP原始碼根目錄執行buildconf.bat
步驟2. 到PHP原始碼根目錄執行configure.bat(或者執行 cscript /nologo configure.js --with-php-build="../win32build" --without-libxml --disable-odbc)
如果沒有之前的set path=%path%;D:\win32build\bin會出現如下提示:
Checking for bison.exe ...
ERROR: bison is required
重新編譯工程,報錯。一大堆的php_stream_transport.h error
形如
..\..\main\streams/php_stream_transport.h(85) : error C2143: syntax error : missing ')' before '*'..\..\main\streams/php_stream_transport.h(85) : error C2081: 'socklen_t' : name in formal parameter list illegal
這是由於找不到宏報的語法錯誤。開啟這個檔案,添加
typedef int socklen_t;
到檔案頭部。
重新編譯工程,不出意外在php原始碼ext子目錄就可以看到php_amf.dll
1 樓 wanluoliang 2011-07-12
非常感謝你的教程。。。。。。。。。。。。。。
2 樓 live711 2011-08-13
你編譯的dll能下載過來直接用嗎?