Applying the Windows SDK on Windows to compile PHP source code

Source: Internet
Author: User
Tags vc9
Compiling PHP source code on Windows using the Windows SDK
Recommend this article: http://vladimirbarbarosh.blogspot.com/2011/05/compile-php-536-pecl-libevent-004.html
In order to facilitate everyone to read, the content is reproduced to everyone, but still encourage to see the original blog post.
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. Just because it takes so much time I decided to publish how to does that. (To is honest we make it together.)
SOURCES
The following is a list of sources so we'll need:
? PHP 5.3.6
? PECL libevent-0.0.4
? libevent-2.0.11-stable
TOOLS
The following is a list of tools, we well need:
? Windows SDK for Windows Server and. NET Framework 3.5
? PHP SDK Binary Tools
? PHP 5.3 depencencies (for the minimal PHP they is not necessary)
1. INSTALL the WINDOWS SDK
I assume that they'll 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 is 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 does 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!
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.