internals:windows:stepbystepbuild_sdk_2
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
internals:windows:stepbystepbuild_sdk_2 [2017/03/30 00:00] – ab | internals:windows:stepbystepbuild_sdk_2 [2021/11/08 14:56] – document Windows phpize builds cmb | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Build your own PHP on Windows ====== | ====== Build your own PHP on Windows ====== | ||
- | This this tutorial concerns the new PHP SDK and PHP 7.2 and later, while the described PHP SDK is compatible with at least PHP 7.0. To build PHP prior to 7.0, or if you experience issues building PHP lower than 7.2 with the new PHP SDK, please refer to [[internals: | + | **This tutorial concerns the new PHP SDK and PHP 7.2 and later, while the described PHP SDK is compatible with at least PHP 7.0. To build PHP prior to 7.0, or if you experience issues building PHP lower than 7.2 with the new PHP SDK, please refer to [[internals: |
===== Before you Begin ===== | ===== Before you Begin ===== | ||
Line 14: | Line 14: | ||
==== Requirements ==== | ==== Requirements ==== | ||
- | PHP officially supports building with Microsoft' | + | PHP officially supports building with Microsoft' |
* Visual C++ 14.0 (Visual Studio 2015) for **PHP 7.0** or **PHP 7.1**. | * Visual C++ 14.0 (Visual Studio 2015) for **PHP 7.0** or **PHP 7.1**. | ||
- | * Visual C++ 15.0 (Visual Studio 2017) for **PHP 7.2** | + | * Visual C++ 15.0 (Visual Studio 2017) for **PHP 7.2**, **PHP 7.3** or **PHP 7.4**. |
- | * | + | * Visual C++ 16.0 (Visual Studio 2019) for **master**. |
+ | |||
+ | Always keep your installed Visual C++ up to date. Otherwise build errors may occur due to dependencies built with newer versions. | ||
+ | |||
+ | Support for a certain Visual Studio version means only support for its default platform toolset; building PHP with a non-default platform toolset (such as 14.16 with Visual Studio 2019) may work, but is not recommended. | ||
+ | |||
+ | In filenames (and the '' | ||
==== Setup ==== | ==== Setup ==== | ||
- | * Fetch the latest stable SDK tag from https:// | + | * Fetch the latest stable SDK tag from https:// |
* The new PHP SDK is required, when building PHP 7.2+ | * The new PHP SDK is required, when building PHP 7.2+ | ||
* Read the PHP SDK specific notes on the Github repository page | * Read the PHP SDK specific notes on the Github repository page | ||
* If compiling **PHP 7.0+**: | * If compiling **PHP 7.0+**: | ||
* Install Visual Studio 2015 | * Install Visual Studio 2015 | ||
+ | * If compiling **PHP 7.2+**: | ||
+ | * Install Visual Studio 2017 | ||
+ | * If compiling **master**: | ||
+ | * Install Visual Studio 2019 | ||
* Optional tools | * Optional tools | ||
Line 34: | Line 45: | ||
==== Command prompt ==== | ==== Command prompt ==== | ||
- | The PHP SDK 2.0.0+ provides starter scripts, that automaticaly | + | The PHP SDK 2.0.0+ provides starter scripts, that automatically |
* PHP_SDK_ARCH - the target build architecture used for environment setup | * PHP_SDK_ARCH - the target build architecture used for environment setup | ||
* PHP_SDK_OS_ARCH - the operating system architecture | * PHP_SDK_OS_ARCH - the operating system architecture | ||
* PHP_SDK_PHP_CMD - integrated PHP binary wrapper script | * PHP_SDK_PHP_CMD - integrated PHP binary wrapper script | ||
- | * PHP_SDK_ROOT_PATH - the path to the PHP SDK rood directory | + | * PHP_SDK_ROOT_PATH - the path to the PHP SDK root directory |
- | * PHP_SDK_VC | + | * PHP_SDK_VS |
* several other less relevant vars are available, that can be viewed by the '' | * several other less relevant vars are available, that can be viewed by the '' | ||
The full list of the tools included with the PHP SDK can be found on the repository readme page. | The full list of the tools included with the PHP SDK can be found on the repository readme page. | ||
- | Each version of Visual Studio (or Windows SDK) provides a command prompt environment for compiling (available from the Start Menu group). It is usable, for example, if you want to ommit the starter scripts usage or want to test a pre release Visual Studio version. | + | Each version of Visual Studio (or Windows SDK) provides a command prompt environment for compiling (available from the Start Menu group). It is usable, for example, if you want to omit the starter scripts usage or want to test a pre release Visual Studio version. |
* If compiling **PHP 7.0+** open either the **" | * If compiling **PHP 7.0+** open either the **" | ||
Line 57: | Line 68: | ||
* clone the [[http:// | * clone the [[http:// | ||
- Get the binary tools: | - Get the binary tools: | ||
- | * available from [[https:// | + | * available from [[https:// |
* either fetch a tag as zip, or clone the git repository and checkout the tag | * either fetch a tag as zip, or clone the git repository and checkout the tag | ||
- Get the libraries on which PHP depends: | - Get the libraries on which PHP depends: | ||
- | * use the PHP SDK tools to fetch the suitable dependencies automatically by calling '' | + | * use the PHP SDK tools to fetch the suitable dependencies automatically by calling '' |
- | * download the packaged deps from [[http:// | + | * alternatively, |
- | * dependency archives are named '' | + | |
- | | + | |
* **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/ | * **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/ | ||
Line 77: | Line 86: | ||
- Run the '' | - Run the '' | ||
- The '' | - The '' | ||
- | - Extract the PHP source code to '' | + | - Extract the PHP source code to '' |
- | * '' | + | * '' |
* '' | * '' | ||
* For example: '' | * For example: '' | ||
- In the same directory where you extracted the PHP source there is a '' | - In the same directory where you extracted the PHP source there is a '' | ||
* switch into the php source directory and run '' | * switch into the php source directory and run '' | ||
- | * If you downloaded the dependencies manually in the perevious | + | * If you downloaded the dependencies manually in the previous |
===== Compile ===== | ===== Compile ===== | ||
Line 90: | Line 99: | ||
- Invoke the starter script to automatically setup the environment for the desired build config, fe <code bash> | - Invoke the starter script to automatically setup the environment for the desired build config, fe <code bash> | ||
- | - Change directory to the location of your PHP source code, e.g. <code bash> | + | - Change directory to the location of your PHP source code, e.g. <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> | ||
Line 96: | Line 105: | ||
- To build PHP, run: <code bash> | - To 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 " |
- | * If you compiled with " | + | * If you compiled with " |
==== Recompile after you have done some changes ==== | ==== Recompile after you have done some changes ==== | ||
Line 128: | Line 137: | ||
At this point, your compiled extension will be located in the release directory. | At this point, your compiled extension will be located in the release directory. | ||
+ | |||
+ | ==== Building PECL extensions with phpize ==== | ||
+ | |||
+ | Alternatively to the " | ||
+ | |||
+ | - Download and unpack the development package which corresponds to your pre-built PHP version and variant from https:// | ||
+ | - Download and unpack the source of the PECL extension | ||
+ | - Invoke the starter script to automatically setup the environment for the desired build config, e.g. '' | ||
+ | - Add the development package folder and the PHP folder to the '' | ||
+ | - Enter the source folder of the PECL extension | ||
+ | - Run '' | ||
+ | - Run '' | ||
+ | * the most important option is the one which enables the extension to be built (e.g. '' | ||
+ | * another important options is '' | ||
+ | * if the extension depends on C libraries, you need to download these and put them either in the '' | ||
+ | * there may be further interesting configuration options, e.g. those which allows to configure details of the extension to be built | ||
+ | - Run '' | ||
+ | - Run '' | ||
+ | - After successful compilation, | ||
+ | - If the extension has a PHPT test suite, run '' | ||
+ | |||
+ | If you want to build your extension via Github Actions, consider to use https:// | ||
+ | |||
+ | ==== Release directories ==== | ||
+ | |||
+ | When you have successfully compiled PHP, the release directory can be one of multiple, depending on the build configuration: | ||
+ | |||
+ | - `Release`: Release NTS build | ||
+ | - `Release_TS`: | ||
+ | - `Debug`: Debug NTS build | ||
+ | - `Debug_TS`: Debug ZTS build | ||
+ | |||
+ | If you are compiling using a 64-bit compiler, then these directories will be located in a directory called `x64`. | ||
===== Pitfalls ===== | ===== Pitfalls ===== | ||
- For possible PHP SDK issues, please consult the PHP SDK readme | - For possible PHP SDK issues, please consult the PHP SDK readme | ||
+ | - As of PHP 7.3 the switch --enable-native-intrinsics is available. The resulting binary will then require a processor with the corresponding feature set available. For example, if you set --enable-native-intrinsics=avx2, | ||
+ | - In some circumstances, | ||
internals/windows/stepbystepbuild_sdk_2.txt · Last modified: 2022/01/10 09:43 by cmb