internals:windows:stepbystepbuild
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
internals:windows:stepbystepbuild [2015/03/26 00:01] – fixed heading levels cmb | internals:windows:stepbystepbuild [2017/09/22 13:28] – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Build your own PHP on Windows ====== | ====== Build your own PHP on Windows ====== | ||
+ | |||
+ | **This tutorial concerns building PHP before 7.2. To build PHP 7.2+, please refer to the [[internals: | ||
===== Before you Begin ===== | ===== Before you Begin ===== | ||
Line 8: | Line 10: | ||
- The PHP source | - The PHP source | ||
- | ===== The Build Environment | + | ===== Compiler |
- | + | ||
- | This is the hardest part of the PHP windows build system to set up and will take up a lot of space on your hard drive - you need to have several GB of space free. | + | |
==== Requirements ==== | ==== Requirements ==== | ||
- | * PHP officially supports building with Microsoft' | + | PHP officially supports building with Microsoft' |
- | * Visual C++ 6.0 for PHP 5.2 | + | |
- | * Visual C++ 9.0 (Visual Studio 2008 or Visual C++ 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 | + | * Visual C++ 9.0 (Visual Studio 2008 or Visual C++ 2008) for **PHP 5.4**. |
- | * Various tools, see [[http:// | + | * Visual C++ 11.0 (Visual Studio 2012) for **PHP 5.5 or 5.6**. |
+ | * Visual C++ 14.0 (Visual Studio 2015) for **PHP 7.0+**. | ||
+ | |||
+ | If using VC9, you will also need the [[http:// | ||
==== Setup ==== | ==== Setup ==== | ||
- | === Quick 'n' | + | * If compiling **PHP 5.4**: |
+ | * Install Visual Studio 2008 | ||
+ | * Install [[http:// | ||
+ | * If compiling **PHP 5.5 or 5.6**: | ||
+ | * Install Visual Studio 2012. If using the express version, install " | ||
+ | * If compiling **PHP 7.0+**: | ||
+ | * Install Visual Studio 2015 | ||
+ | |||
+ | ==== Command prompt ==== | ||
+ | |||
+ | Each version of Visual Studio (or Windows SDK) provides a command prompt environment for compiling (available from the Start Menu group). | ||
+ | |||
+ | * If compiling **PHP 5.4**, open the **" | ||
+ | * If compiling **PHP 5.5 or 5.6** open the **" | ||
+ | * If compiling **PHP 7.0+** open either the **" | ||
+ | |||
+ | All commands in the rest of this document should be run in the appropriate command prompt. | ||
+ | |||
+ | ===== Download prerequisites ===== | ||
+ | |||
+ | - Get the PHP source, there are two alternatives: | ||
+ | * download a source archive ([[http:// | ||
+ | * clone the [[http:// | ||
+ | - Get the binary tools: | ||
+ | * available from [[http:// | ||
+ | * the binary tools archives are named php-sdk-binary-tools-YYYYMMDD.zip, | ||
+ | - Get the libraries on which PHP depends: | ||
+ | * download the packaged deps from [[http:// | ||
+ | * dependency archives are named '' | ||
+ | * chose the archive which matches your desired PHP version and architecture, | ||
+ | * **Note:** This 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/ | ||
+ | |||
+ | ===== Setup the build directory ===== | ||
+ | |||
+ | This should be done only once before building PHP. | ||
+ | |||
+ | - Create the build directory '' | ||
+ | - Unpack the binary tools archive into this directory, it should contain three sub-directories: | ||
+ | - Open the command prompt and enter the build directory: <code bash>cd c: | ||
+ | - Run the '' | ||
+ | - The '' | ||
+ | * If compiling for **VC11**: copy '' | ||
+ | * If compiling for **VC14**: copy '' | ||
+ | - Extract the PHP source code to '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * For example: '' | ||
+ | - In the same directory where you extracted the PHP source there is a '' | ||
+ | |||
+ | ===== Compile ===== | ||
- | | + | - Open the command prompt |
- | - Install Visual Studio 2008 (no matter what version -express, pro or others; all should work) and install it | + | - Set up the build environment variables: |
- | - Get and install Windows SDK 6.1 | + | - Change directory to the location of your PHP source code, e.g. <code bash>cd C: |
- | - If compiling **PHP 5.5+**: | + | |
- | - Install Visual Studio 2012. If using the express version, install " | + | |
- | - Get PHP via [[http:// | + | |
- | - Create the folder “c: | + | |
- | - Unpack the binary-tools.zip archive (http:// | + | |
- | - If compiling **PHP 5.3 or 5.4**: | + | |
- | | + | |
- | - If compiling **PHP 5.5+**: | + | |
- | - Open " | + | |
- | - Execute the following commands: <code bash>cd c: | + | |
- | - If compiling for **vc11**: | + | |
- | - Copy c: | + | |
- | - Now extract the PHP source code to C: | + | |
- | - In the same directory (C: | + | |
- | - See also: http:// | + | |
- | - Change directory to the location of your PHP source code: <code bash>cd C: | + | |
- Run: <code bash> | - Run: <code bash> | ||
- To get an overview of the compiling flags: <code bash> | - To get an overview of the compiling flags: <code bash> | ||
- Create your configure command: <code bash> | - Create your configure command: <code bash> | ||
- | | + | |
- | - Build PHP, run: <code bash> | + | |
- If you want the resulting PHP builds and extensions to be zipped, after ' | - If you want the resulting PHP builds and extensions to be zipped, after ' | ||
- The compiled PHP is now under " | - The compiled PHP is now under " | ||
- | | + | |
- | === Recompile after you have done some changes === | + | ==== Recompile after you have done some changes |
- Clean up old compiled binaries <code bash> | - Clean up old compiled binaries <code bash> | ||
Line 61: | Line 93: | ||
- Compile <code bash> | - Compile <code bash> | ||
- | === Adding | + | ==== Building |
- | - <code bash>cd C: | + | Many PECL extensions already have prebuilt DLLs which can be downloaded from the extension |
- | - Get the dbase extension | + | |
- | - <code bash>svn co http://svn.php.net/repository/pecl/ | + | |
- | - <code bash>cd php-source-directory</ | + | |
- | - <code bash> | + | |
- | - Executing <code bash> | + | |
- | - <code bash> | + | |
- | - <code bash> | + | |
- | - Test the binary with a <code bash>php -m</ | + | |
- | * Additional Links: | + | To build a PECL extension |
- | * [[ http:// | + | |
- | * [[http:// | + | |
- | === LDAP Support Notes === | + | - Open the extension' |
+ | - Download the extension source either by: | ||
+ | * downloading a source archive | ||
+ | * fetching the source from the extension' | ||
+ | - Create a directory named **'' | ||
+ | - Extract or clone the extension source code to the '' | ||
+ | * if cloning, clone to a subdirectory, | ||
+ | * source code archive should already contain a subdirectory named e.g. '' | ||
+ | - Open a command prompt, run the '' | ||
+ | - Rebuild the configure script by running: <code bash> | ||
+ | - Executing '' | ||
+ | - Configure and build: <code bash> | ||
+ | - Test the binary with a '' | ||
+ | |||
+ | At this point, your compiled extension will be located in the release directory. | ||
+ | |||
+ | Additional Links: | ||
+ | * [[ http:// | ||
+ | * [[http:// | ||
+ | |||
+ | ==== LDAP Support Notes ==== | ||
- Add " | - Add " | ||
- Make sure to package your generated binaries with libsasl.dll, | - Make sure to package your generated binaries with libsasl.dll, | ||
- | ==== Pitfalls ==== | + | ===== Pitfalls ===== |
+ | |||
+ | **fatal error C1900: [] mismatch between ' | ||
- | **fatal error C1900: [] mismatch between ' | + | If you are using Visual Studio 2008 Express and Platform SDK 6.1 make sure you have the latest versions and check for version incompatibilities. There are known issues with old versions of VS 2008 Express and Platform SDK 6.1. |
- | ** | + | |
- | If you are using Visual Studio 2008 Express and Platform SDK 6.1 make sure you have the latest versions and check for version incompatibilities. There are known issues with old versions of VS 2008 Express and Platform SDK 6.1. | + | |
The order in which you install the Visual Studio 2008 Express Edition and Platform SDK 6.1 is important due to the issue reported in [[http:// | The order in which you install the Visual Studio 2008 Express Edition and Platform SDK 6.1 is important due to the issue reported in [[http:// | ||
Line 92: | Line 134: | ||
Make sure that you are running setenv /xp /x86. For example, setenv /xp /x64 or setenv /vista /x64 causes the above error message even if you are using Visual Studio 2008 Express SP1 and Platform SDK 6.1 (60001.18000.367) on a Vista 64bit system. | Make sure that you are running setenv /xp /x86. For example, setenv /xp /x64 or setenv /vista /x64 causes the above error message even if you are using Visual Studio 2008 Express SP1 and Platform SDK 6.1 (60001.18000.367) on a Vista 64bit system. | ||
- | ==== Utilities ==== | + | ===== Utilities |
- | === Resource Hacker === | + | ==== Resource Hacker |
Utility to show dependency information and other assembly information from a DLL. For instance, it shows which version of the Visual C++ Runtime the DLL was linked against. | Utility to show dependency information and other assembly information from a DLL. For instance, it shows which version of the Visual C++ Runtime the DLL was linked against. | ||
Get it here: http:// | Get it here: http:// |
internals/windows/stepbystepbuild.txt · Last modified: 2019/11/15 21:57 by nikic