在windows上使用windows sdk编译php源码

推荐这篇文章:[url=http://vladimirbarbarosh.blogspot.com/2011/05/compile-php-536-pecl-libevent-004.html]http://vladimirbarbarosh.blogspot.com/2011/05/compile-php-536-pecl-libevent-004.html[/url]
为了方便大家阅读,将内容转载给大家,不过还是鼓励去看原创博文。
Compile php-5.3.6 + pecl-libevent-0.0.4 + libevent-2.0.11-stable
Yesterday a friend of mine ask me to compile libevent [url=http://pecl.php.net/package/libevent]PHP extension[/url] for Windows. It takes me about a whole day to figure out how to do that. Just because it takes so much time I decided to publish how to do that. (To be honest we make it together.)
SOURCES
The following is a list of sources that we will need:
• [url=http://php.net/downloads.php]PHP 5.3.6[/url]
• [url=http://pecl.php.net/package/libevent]PECL libevent-0.0.4[/url]
• [url=http://monkey.org/~provos/libevent/]libevent-2.0.11-stable[/url]
TOOLS
The following is a list of tools that we well need:
• [url=http://www.microsoft.com/downloads/en/details.aspx?FamilyID=F26B1AA4-741A-433A-9BE5-FA919850BDBF]Windows SDK for Windows Server 2008 and .NET Framework 3.5[/url]
• [url=http://windows.php.net/downloads/php-sdk/php-sdk-binary-tools-20110512.zip]PHP SDK Binary Tools[/url]
• [url=http://windows.php.net/downloads/php-sdk/deps-5.3-vc9-x86.7z]PHP 5.3 Depencencies[/url] (for the minimal PHP they are not necessary)
1. INSTALL WINDOWS SDK
I assume that they will be installed into c:\sdk directory.
2. CREATE C:\PHPSDK DIRECTORY
This is our workplace. I find it much easier to explain, read, and follow how to create it usingpseudo-code rather than words:
mkdir c:\phpsdk
pushd c:\phpsdk
extract http://windows.php.net/downloads/php-sdk/php-sdk-binary-tools-20110512.zip
bin\phpsdk_setvars.bat
bin\phpsdk_buildtree.bat php-5.3.6
pushd php-5.3.6\vc9\x86
extract http://md.php.net/distributions/php-5.3.6.tar.bz2
mv php-5.3.6 src
extract http://windows.php.net/downloads/php-sdk/deps-5.3-vc9-x86.7z
popd

extract http://pecl.php.net/get/libevent-0.0.4.tgz
rm package.xml
mv libevent-0.0.4 php_libevent
pushd php_libevent
extract http://monkey.org/~provos/libevent-2.0.11-stable.tar.gz
popd
popd
3. COMPILE MINIMAL PHP
cmd /e:on /v:on
c:\sdk\bin\setenv.cmd /x86 /xp /release
c:\phpsdk\bin\phpsdk_setvars.bat
cd c:\phpsdk\php-5.3.6\vc9\x86\src
buildconf
configure --disable-all --enable-cli
nmake
rem The following command creates php-5.3.6-devel-VC9-x86
rem directory which gives us extension developer's header
rem and .lib files
nmake snap
4. COMPILE LIBEVENT-2.0.11-STABLE
cmd /e:on /v:on
c:\sdk\bin\setenv.cmd /x86 /xp /release
c:\phpsdk\bin\phpsdk_setvars.bat
cd c:\phpsdk\php_libevent\libevent-2.0.11-stable
nmake -f Makefile.nmake
5. COMPILE PHP_LIBEVENT.DLL
This was the most trickier part.
cmd /e:on /v:on
c:\sdk\bin\setenv.cmd /x86 /xp /release
c:\phpsdk\bin\phpsdk_setvars.bat
cd c:\phpsdk\php_libevent
set phpdevdir=c:\phpsdk\php-5.3.6\vc9\x86\src\Release_TS\php-5.3.6-devel-VC9-x86
set libeventdir=c:\phpsdk\libevent\libevent-2.0.11-stable

cl libevent.c ^
/c ^
/Fophp_libevent.obj ^
/DZEND_WIN32 ^
/DPHP_WIN32 ^
/DWIN32 ^
/DZTS=1 ^
/DZEND_DEBUG=0 ^
/DCOMPILE_DL_LIBEVENT ^
/I%phpdevdir%\include\Zend ^
/I%phpdevdir%\include\main ^
/I%phpdevdir%\include\TSRM ^
/I%phpdevdir%\include ^
/I%libeventdir%\WIN32-Code ^
/I%libeventdir%\include ^
/I%libeventdir%

link php_libevent.obj ^
/DLL ^
php5ts.lib /LIBPATH:%phpdevdir%\lib ^
libevent.lib /LIBPATH:%libeventdir% ^
ws2_32.lib
6. TESTING PHP_LIBEVENT.DLL
cd c:\phpsdk\php-5.3.6\vc9\x86\src\Release_TS\php-5.3.6
copy php.ini-development php.ini
echo extension=c:\phpsdk\php_libevent\php_libevent.dll >> php.ini
php -m
FILES
• php-5.3.6-libevent-ts.zip
• phpsdk-libevent-skeleton.zip (skeleton of our workspace directory)
REFERENCES
• Build your own PHP on Windows
• How do I compile an extension for PHP 5.3 for windows as a DLL?
• Creating a PHP 5 Extension with Visual C++ 2005
• Creating a PHP Extension for Windows using Microsoft Visual C++ 2008
• Compiling PHP for Windows Vista using Visual C++ Express 2008 – Seriously!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值