internals:windows:stepbystepbuild
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
internals:windows:stepbystepbuild [2012/10/05 19:23] – adding Resource Hacker tool mattficken | internals:windows:stepbystepbuild [2019/11/15 21:57] (current) – nikic | ||
---|---|---|---|
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 ==== | ||
- | * 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). | + | PHP officially supports building with Microsoft' |
- | * The correct Windows SDK or Platform SDK to match your compiler. | + | |
- | * Various tools, see [[http:// | + | |
- | ===== Setup ===== | + | |
- | == Quick ' | + | * Visual C++ 9.0 (Visual Studio 2008 or Visual C++ 2008) for **PHP 5.4**. |
+ | * 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+**. | ||
- | - get visual studio 2008 (no matter what version - [[http:// | + | If using VC9, you will also need the [[http:// |
- | - get and install windows sdk 6.1 | + | |
- | - get a php 5.3 [[http:// | + | |
- | - create the folder “c: | + | |
- | - unpack the binary-tools.zip archive (http:// | + | |
- | - open the “windows sdk 6.1 shell” (it’s available from the start menu group) and execute the following commands in it: | + | |
- | - <code bash> | + | |
- | - <code bash>cd c: | + | |
- | - <code bash> | + | |
- | - <code bash> | + | |
- | - now extract the snapshot from 3) to C: | + | |
- | - in the same directory (C: | + | |
- | - run in the windows-sdk-shell: | + | |
- | - <code bash> | + | |
- | - to get an overview of the compiling flags: <code bash> | + | |
- | - create your configure command: <code bash> | + | |
- | - <code bash> | + | |
- | - if you want the resulting php to be zipped (comes handy for redist, believe me!), run after this also: <code bash> | + | |
- | - the compiled php is now under C: | + | |
- | == Adding PECL extensions (using ' | + | ==== Setup ==== |
- | | + | |
- | - get the dbase extension code through Subversion | + | * Install Visual Studio 2008 |
- | - <code bash>svn co http://svn.php.net/repository/pecl/dbase/trunk pecl/ | + | * Install [[http://www.microsoft.com/en-us/download/details.aspx? |
- | | + | |
- | - <code bash> | + | * Install Visual Studio 2012. If using the express version, install " |
- | - executing <code bash> | + | |
- | - <code bash> | + | * Install Visual Studio 2015 |
- | | + | |
- | - test the binary with a <code bash>php -m</ | + | |
- | == LDAP Support Notes == | + | ==== Command prompt ==== |
- | - add " | + | Each version of Visual Studio (or Windows SDK) provides a command prompt environment for compiling (available |
- | - make sure to package your generated binaries with libsasl.dll, | + | |
- | === Pitfalls === | + | * 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 **" | ||
- | == fatal error C1900: [] mismatch between ' | + | All commands in the rest of this document should be run in the appropriate command prompt. |
- | 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. | + | ===== 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 and enter the build directory: <code bash>cd c: | ||
+ | - Set up the build environment variables: <code bash> | ||
+ | - Change directory to the location of your PHP source code, e.g. <code bash>cd C: | ||
+ | - Run: <code bash> | ||
+ | - To get an overview of the compiling flags: <code bash> | ||
+ | - Create your configure command: <code bash> | ||
+ | - To build PHP, run: <code bash> | ||
+ | - If you want the resulting PHP builds and extensions to be zipped, after ' | ||
+ | - The compiled PHP is now under " | ||
+ | * If you compiled with " | ||
+ | |||
+ | ==== Recompile after you have done some changes ==== | ||
+ | |||
+ | - Clean up old compiled binaries <code bash> | ||
+ | - If you need to update the ' | ||
+ | - Create your makefile: see [[internals/ | ||
+ | - Compile <code bash> | ||
+ | |||
+ | ==== Building PECL extensions ==== | ||
+ | |||
+ | Many PECL extensions already have prebuilt DLLs which can be downloaded from the extension page on the PECL web site. For example, on the [[https:// | ||
+ | |||
+ | To build a PECL extension (for example APCu): | ||
+ | |||
+ | - 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 " | ||
+ | - Make sure to package your generated binaries with libsasl.dll, | ||
+ | |||
+ | ===== Pitfalls ===== | ||
+ | |||
+ | **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. | ||
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 68: | 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.1349464993.txt.gz · Last modified: 2017/09/22 13:28 (external edit)