internals:windows:stepbystepbuild

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

internals:windows:stepbystepbuild [2012/11/12 22:32]
szarkos Added PHP 5.5+ build 'setenv' option change.
internals:windows:stepbystepbuild [2013/06/18 23:28] (current)
szarkos
Line 14: Line 14:
 ==== Requirements ==== ==== Requirements ====
  
-  * Microsoft Visual C++, PHP officially supports building with Visual C++ 6.0 or with Visual C++ 9 (also known as Visual C++ 2008 just to be confusing). ​ You can use the Express versions as well.  MinGW and other compilers are NOT supported or even known to work.  For more information and how to get the compiler see the [[internals:​windows:​compiler|supported versions]] +  * PHP officially supports building with Microsoft'​s ​Visual C++ compilers.  MinGW and other compilers are NOT supported or even known to work.  For more information and how to get the compiler see the [[internals:​windows:​compiler|supported versions]].  The following VC versions are supported: 
-  * The correct Windows SDK or Platform SDK to match your compiler. ​  see this [[internals:​windows:​windowssdk|page]] for the supported versions +    * Visual C++ 6.0 for PHP 5.2 
-  * Various tools, see [[http://​windows.php.net/​downloads/​php-sdk/​]] for binary versions of them+    * Visual C++ 9.0 (Visual Studio 2008) for PHP 5.3 and 5.4.  You can use the Express versions as well. 
 +    ​Visual C++ 11.0 (Visual Studio 2012) for PHP 5.5+.  You can use the Express versions as well. 
 + 
 +  * If using VC9 or earlier, you will need the correct Windows SDK or Platform SDK to match your compiler. ​ ​See ​this [[internals:​windows:​windowssdk|page]] for the supported versions. 
 +  * Various tools, see [[http://​windows.php.net/​downloads/​php-sdk/​]] for binary versions of them
 ===== Setup ===== ===== Setup =====
  
-== Quick '​n' ​easy ==+== Quick '​n' ​Easy ==
  
-  - get visual studio ​2008 (no matter what version - [[http://​www.microsoft.com/​express/​downloads/#​Visual_Studio_2008_Express_Downloads | express]], pro or others; all should work) and install it +  - If compiling **PHP 5.3 or 5.4**: 
-  get and install ​windows sdk 6.1 +    - Install Visual Studio ​2008 (no matter what version - [[http://​www.microsoft.com/​express/​downloads/#​Visual_Studio_2008_Express_Downloads | express]], pro or others; all should work) and install it 
-  - get a php 5.[[http://​snaps.php.net | snapshot ]] (do not extract yet!) +    Get and install ​Windows SDK 6.1 
-  - create ​the folder “c:​\php-sdk“ +  - If compiling **PHP 5.5+**: 
-  - unpack ​the binary-tools.zip archive (http://​windows.php.net/​downloads/​php-sdk/​) into this directory, there should be one sub-directory called “bin” and one called “script“ +    - Install Visual Studio 2012 ([[http://​www.microsoft.com/​visualstudio/​eng/​downloads | VS 2012 Downloads]]). If using the express version, install "​Visual Studio 2012 Express for Windows Desktop"​ 
-  - open the “windows sdk 6.1 shell” (its available from the start menu group) and execute the following ​commands ​in it: +  - Get PHP via [[http://​git.php.net | git ]] or a [[http://​snaps.php.net | snapshot ]] (do not extract yet!) 
-    - **PHP 5.2, 5.3 and 5.4:​** ​<code bash>​setenv /x86 /xp /​release</​code>​ +  - Create ​the folder “c:​\php-sdk“ 
-    - **PHP 5.5+:** <code bash>​setenv /x86 /2008 /​release</​code>​ +  - Unpack ​the binary-tools.zip archive (http://​windows.php.net/​downloads/​php-sdk/​) into this directory, there should be one sub-directory called “bin” and one called “script“ 
-  - <code bash>cd c:​\php-sdk\</​code>​ +  - If compiling **PHP 5.3 or 5.4**: 
-  - <code bash>​bin\phpsdk_setvars.bat</​code>​ +    - Open the "​Windows SDK 6.1 shell" ​(it's available from the start menu group) and execute the following ​command ​in it: <code bash>​setenv /x86 /xp /​release</​code>​ 
-  - <code bash>​bin\phpsdk_buildtree.bat ​php53dev</​code>​ +  If compiling ​**PHP 5.5+**
-  - now extract the snapshot from 3) to C:\php-sdk\php53dev\vc9\x86 with your favourite ​unpacker (winrar ​should handle it) so that the following directory gets created: ​C:\php-sdk\php53dev\vc9\x86\php5.3-xyz +    - Open "​VS2012 ​x86 Native Tools Command Prompt"​ (it's available from the start menu group): 
-  - in the same directory (C:​\php-sdk\php53dev\vc9\x86) there is a "​deps"​ folderextract ​any of your required ​libraries ​inside ​that folder (see http://​wiki.php.net/​internals/​windows/​libs) but make sure their top-level contains /include and /lib (some of them have an extra directory level in there) +  - Execute the following commands: ​<code bash>cd c:​\php-sdk\</​code>​ <code bash>​bin\phpsdk_setvars.bat</​code>​ <code bash>​bin\phpsdk_buildtree.bat ​phpdev</​code>​ 
-  - run in the windows-sdk-shell: <code bash>cd C:\php-sdk\php53dev\vc9\x86\php5.3-xyz</​code>​ +  - Now extract the PHP source code to C:\php-sdk\phpdev\**vcXX**\x86 with your favorite ​unpacker (7-zip should handle it) where **vcXX** is the compiler version you are using. For example ​C:\php-sdk\phpdev\vc11\x86\<php-source-directory>​ 
-  - <code bash>​buildconf</​code>​ +  - In the same directory (C:​\php-sdk\phpdev\vcXX\x86) there is a "​deps"​ folder.  Here you will need to extract ​all the libraries ​required to build PHP.  We have packaged the required deps for most of the core extensions at http://​windows.php.net/​downloads/​php-sdk/​. Simply download the appropriate file that matches your PHP version and extract to C:​\php-sdk\phpdev\vcXX\x86\deps 
-  - to get an overview of the compiling flags: <code bash>​configure --help</​code>​ +    - See also: http://​wiki.php.net/​internals/​windows/​libs 
-  - create ​your configure command: <code bash>​configure --disable-all --enable-cli --enable-$remains</​code> ​(warning: some extensions need libraries, header files and helper apps, see [[internals/​windows/​libs]],​ fetch the version you need and extract the archive ​in the deps directory, ​ie: c:\php-sdk\php53\vc9\x86\deps) +  - Change directory to the location of your PHP source code: <code bash>cd C:\php-sdk\phpdev\vcXX\x86\php-source-directory</​code>​ 
-  - <code bash>​nmake</​code>​ +  - Run: <code bash>​buildconf</​code>​ 
-  - if you want the resulting ​php to be zipped ​(comes handy for redistbelieve me!), run after this also: <code bash>​nmake snap</​code>​ +  - To get an overview of the compiling flags: <code bash>​configure --help</​code>​ 
-  - the compiled ​php is now under C:\php-sdk\php53dev\vc9\x86\php5.3-SNAPSHOTTIME\Release_TS, same as the zip file (if you created it).+  - Create ​your configure command: <code bash>​configure --disable-all --enable-cli --enable-$remains</​code>​ 
 +    - **Note:** The deps located at http://​windows.php.net/​downloads/​php-sdk/​ should include the libraries needed to build most the core extensions. However, ​some other extensions ​may need additional ​libraries, header files and helper apps.  See [[internals/​windows/​libs]],​ fetch the version you need and extract the archive ​into the deps directory, ​i.e.: c:\php-sdk\phpdev\vcXX\x86\deps) 
 +  - Build PHP, run: <code bash>​nmake</​code>​ 
 +  - If you want the resulting ​PHP builds and extensions ​to be zipped, after '​nmake' ​also run: <code bash>​nmake snap</​code>​ 
 +  - The compiled ​PHP is now under "C:\php-sdk\phpdev\vcXX\x86\php-source-directory\Release_TS"​. ​ If you ran 'nmake snap' ​the zip file will also be here. 
 +    - If you compiled with "​--disable-zts"​ the compiled PHP will be under "​C:​\php-sdk\phpdev\vcXX\x86\php-source-directory\Release"​ 
 + 
 +== Recompile after you have done some changes == 
 + 
 +  - Clean up old compiled binaries <code bash>​nmake clean</​code>​ 
 +  - If you need to update the '​configure'​ script <code bash>​buildconf --force</​code>​ 
 +  - Create your makefile: see [[internals/​windows/​release]]<​code bash>​configure --disable-all --enable-cli --enable-$remains</​code>​ 
 +  - Compile <code bash>​nmake</​code>​
  
 == Adding PECL extensions (using '​dbase'​ as an example) == == Adding PECL extensions (using '​dbase'​ as an example) ==
  
-  - <code bash>cd C:\php-sdk\php53dev\vc9\x86</​code>​ +  - <code bash>cd C:\php-sdk\phpdev\vcXX\x86</​code>​ 
-  - get the dbase extension code through Subversion+  - Get the dbase extension code through Subversion
   - <code bash>svn co http://​svn.php.net/​repository/​pecl/​dbase/​trunk pecl/​dbase</​code>​   - <code bash>svn co http://​svn.php.net/​repository/​pecl/​dbase/​trunk pecl/​dbase</​code>​
-  - <code bash>​cd ​php5.3-xyz</​code>​+  - <code bash>​cd ​php-source-directory</​code>​
   - <code bash>​buildconf</​code>​   - <code bash>​buildconf</​code>​
-  - executing ​<code bash>​configure --help</​code>​ should now contain a dbase option+  - Executing ​<code bash>​configure --help</​code>​ should now contain a dbase option
   - <code bash>​configure --enable-cli --enable-dbase</​code>​   - <code bash>​configure --enable-cli --enable-dbase</​code>​
   - <code bash>​nmake</​code>​   - <code bash>​nmake</​code>​
-  - test the binary with a <code bash>php -m</​code>​ command, to make sure dbase exists+  - Test the binary with a <code bash>php -m</​code>​ command, to make sure dbase exists 
 + 
 +  * Additional Links: 
 +    * [[ http://​www.ksingla.net/​2010/​05/​adding-a-pecl-extension-to-your-php-build-environment/​ | Adding a PECL extension to your PHP build environment ]] 
 +    * [[http://​php.net/​manual/​en/​install.pecl.windows.php | Installing a PHP extension ]]
  
 == LDAP Support Notes == == LDAP Support Notes ==
  
-  - add "​--with-ldap"​ to your configure +  - Add "​--with-ldap"​ to your configure 
-  - make sure to package your generated binaries with libsasl.dll,​ which will not be built through this process - you can find it inside your C:​\php-sdk\php53dev\vc9\x86\deps\bin\ folder, or you can download it from one of the PHP [[http://​windows.php.net/​download/​|official binary packages]]+  - Make sure to package your generated binaries with libsasl.dll,​ which will not be built through this process - you can find it inside your C:​\php-sdk\php53dev\vc9\x86\deps\bin\ folder, or you can download it from one of the PHP [[http://​windows.php.net/​download/​|official binary packages]]
  
 === Pitfalls === === Pitfalls ===
Line 76: Line 97:
  
 Get it here: http://​angusj.com/​resourcehacker/​ Get it here: http://​angusj.com/​resourcehacker/​
- 
- 
internals/windows/stepbystepbuild.1352755930.txt.gz · Last modified: 2012/11/12 22:32 by szarkos