在windows上使用windows sdk编译php源码
推荐这篇文章:http://vladimirbarbarosh.blogspot.com/2011/05/compile-php-536-pecl-libevent-004.html
为了方便大家阅读,将内容转载给大家,不过还是鼓励去看原创博文。
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 php extension 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:
? php 5.3.6
? pecl libevent-0.0.4
? libevent-2.0.11-stable
tools
the following is a list of tools that we well need:
? windows sdk for windows server 2008 and .net framework 3.5
? php sdk binary tools
? php 5.3 depencencies (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!