How to build PHP 8 Extension on Windows


Read this article first: How to build PHP 8 on Windows

Example, we need to build extension vld:
https://github.com/derickr/vld

We follow 8 first steps in this article

Step 9: download extension source code https://github.com/derickr/vld/archive/refs/heads/master.zip

then unzip to folder F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\ext\vld

Step 10: compile PHP

nmake clean
F:\php-sdk\phpsdk-vs16-x64.bat
buildconf
configure --disable-all --enable-cli --enable-vld=shared
nmake

result:

F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src
$ nmake clean

Microsoft (R) Program Maintenance Utility Version 14.16.27050.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Cleaning SAPI
Cleaning distribution build dirs
        rd /s /q F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS\php-8.2.16
The system cannot find the file specified.

F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src
$ F:\php-sdk\phpsdk-vs16-x64.bat
[vcvarsall.bat] Environment initialized for: 'x64'

PHP SDK 2.2.1-dev

OS architecture:    64-bit
Build architecture: 64-bit
Visual C++:         14.16.27050.0
PHP-SDK path:       F:\php-sdk

F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src
$ buildconf
Rebuilding configure.js
Now run 'configure --help'

F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src
$ configure --disable-all --enable-cli --enable-vld=shared
PHP Version: 8.2.16

Saving configure options to config.nice.bat
Checking for cl.exe ...  <in default path>
  Detected compiler Visual C++ 2019
  Detected x64 compiler
Checking for link.exe ...  <in default path>
Checking for nmake.exe ...  <in default path>
Checking for lib.exe ...  <in default path>
Checking for bison.exe ...  <in default path>
  Detected bison version 3.3.2
Checking for sed.exe ...  <in default path>
Checking for re2c.exe ...  <in default path>
  Detected re2c version 1.1.1
Checking for zip.exe ...  <in default path>
Checking for lemon.exe ...  <in default path>
Checking for 7za.exe ...  <in default path>
Checking for mc.exe ...  C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64
Checking for mt.exe ...  C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64
Enabling multi process build

Build dir: F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS
PHP Core:  php8ts.dll and php8ts.lib
Checking for ML64.exe ...  <in default path>

Checking for wspiapi.h ...  <in default path>
Enabling IPv6 support
Enabling SAPI sapi\cli
Checking for library edit_a.lib;edit.lib ... <in deps path> \lib\edit_a.lib
Checking for editline/readline.h ...  <in deps path> \include
Enabling extension ext\date
Enabling extension ext\hash
Checking for KeccakHash.h ...  ext/hash/sha3/generic64lc
Checking for PMurHash.h ...  ext/hash/murmur
Checking for xxhash.h ...  ext/hash/xxhash
Enabling extension ext\json
Enabling extension ext\pcre
Enabling extension ext\random
Enabling extension ext\reflection
Enabling extension ext\spl
Checking for timelib_config.h ...  ext/date/lib
Enabling extension ext\standard
Enabling extension ext\vld-sourceguardian [shared]

Creating build dirs...
Generating files...
Generating Makefile
Generating main/internal_functions.c
        [content unchanged; skipping]
Generating main/config.w32.h
Generating phpize
Done.



Enabled extensions:
-----------------------
| Extension  | Mode   |
-----------------------
| date       | static |
| hash       | static |
| json       | static |
| pcre       | static |
| random     | static |
| reflection | static |
| spl        | static |
| standard   | static |
| vld        | shared |
-----------------------


Enabled SAPI:
-------------
| Sapi Name |
-------------
| cli       |
-------------


-----------------------------------------
|                     |                 |
-----------------------------------------
| Build type          | Release         |
| Thread Safety       | Yes             |
| Compiler            | Visual C++ 2019 |
| Target Architecture | x64             |
| Host Architecture   | x64             |
| Optimization        | PGO disabled    |
| Native intrinsics   | SSE2            |
| Static analyzer     | disabled        |
-----------------------------------------


Type 'nmake' to build PHP

F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src
$ nmake

Microsoft (R) Program Maintenance Utility Version 14.16.27050.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        type ext\pcre\php_pcre.def > F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS\php8ts.dll.def
branchinfo.c
set.c
srm_oparray.c
vld.c
zend.c
zend_API.c
zend_alloc.c
zend_ast.c
zend_atomic.c
zend_attributes.c
zend_builtin_functions.c
zend_closures.c
zend_compile.c
zend_constants.c
zend_cpuinfo.c
zend_default_classes.c
zend_enum.c
zend_exceptions.c
zend_execute.c
zend_execute_API.c
zend_extensions.c
zend_fibers.c
zend_float.c
zend_gc.c
zend_generators.c
zend_hash.c
zend_highlight.c
zend_inheritance.c
zend_ini.c
zend_ini_parser.c
zend_ini_scanner.c
zend_interfaces.c
zend_iterators.c
zend_language_parser.c
zend_language_scanner.c
zend_list.c
zend_llist.c
zend_multibyte.c
zend_object_handlers.c
zend_objects.c
zend_objects_API.c
zend_observer.c
zend_opcode.c
zend_operators.c
zend_ptr_stack.c
zend_smart_str.c
zend_sort.c
zend_stack.c
zend_stream.c
zend_string.c
zend_strtod.c
zend_system_id.c
zend_variables.c
zend_virtual_cwd.c
zend_vm_opcodes.c
zend_weakrefs.c
block_pass.c
compact_literals.c
compact_vars.c
dce.c
dfa_pass.c
escape_analysis.c
nop_removal.c
optimize_func_calls.c
optimize_temp_vars_5.c
pass1.c
pass3.c
sccp.c
scdf.c
zend_call_graph.c
zend_cfg.c
zend_dfg.c
zend_dump.c
zend_func_info.c
zend_inference.c
zend_optimizer.c
zend_ssa.c
SAPI.c
fopen_wrappers.c
getopt.c
internal_functions.c
main.c
network.c
output.c
php_content_types.c
php_ini.c
php_ini_builder.c
php_odbc_utils.c
php_open_temporary_file.c
php_scandir.c
php_syslog.c
php_ticks.c
php_variables.c
reentrancy.c
rfc1867.c
safe_bcmp.c
snprintf.c
spprintf.c
strlcat.c
strlcpy.c
cast.c
filter.c
glob_wrapper.c
memory.c
mmap.c
plain_wrapper.c
streams.c
transports.c
userspace.c
xp_socket.c
codepage.c
console.c
dllmain.c
fnmatch.c
ftok.c
getrusage.c
glob.c
globals.c
inet.c
ioutil.c
nice.c
readdir.c
registry.c
select.c
sendmail.c
signal.c
sockets.c
time.c
winutil.c
wsyslog.c
TSRM.c
tsrm_win32.c
php_date.c
astro.c
dow.c
interval.c
parse_date.c
parse_iso_intervals.c
parse_posix.c
parse_tz.c
timelib.c
tm2unixtime.c
unixtime2tm.c
hash.c
hash_adler32.c
hash_crc32.c
hash_fnv.c
hash_gost.c
hash_haval.c
hash_joaat.c
hash_md.c
hash_murmur.c
hash_ripemd.c
hash_sha.c
hash_sha3.c
hash_snefru.c
hash_tiger.c
hash_whirlpool.c
hash_xxhash.c
KeccakHash.c
KeccakP-1600-opt64.c
KeccakSponge.c
PMurHash.c
PMurHash128.c
ext\hash\murmur\PMurHash128.c(485): warning C4028: formal parameter 3 different from declaration
json.c
json_encoder.c
json_parser.tab.c
json_scanner.c
php_pcre.c
pcre2_auto_possess.c
pcre2_chartables.c
pcre2_compile.c
pcre2_config.c
pcre2_context.c
pcre2_convert.c
pcre2_dfa_match.c
pcre2_error.c
pcre2_extuni.c
pcre2_find_bracket.c
pcre2_jit_compile.c
pcre2_maketables.c
pcre2_match.c
pcre2_match_data.c
pcre2_newline.c
pcre2_ord2utf.c
pcre2_pattern_info.c
pcre2_script_run.c
pcre2_serialize.c
pcre2_string_utils.c
pcre2_study.c
pcre2_substitute.c
pcre2_substring.c
pcre2_tables.c
pcre2_ucd.c
pcre2_valid_utf.c
pcre2_xclass.c
random.c
engine_combinedlcg.c
engine_mt19937.c
engine_pcgoneseq128xslrr64.c
engine_secure.c
engine_user.c
engine_xoshiro256starstar.c
randomizer.c
php_reflection.c
php_spl.c
spl_array.c
spl_directory.c
spl_dllist.c
spl_exceptions.c
spl_fixedarray.c
spl_functions.c
spl_heap.c
spl_iterators.c
spl_observer.c
array.c
assert.c
base64.c
basic_functions.c
browscap.c
crc32.c
crc32_x86.c
credits.c
crypt.c
crypt_blowfish.c
crypt_freesec.c
crypt_sha256.c
crypt_sha512.c
css.c
datetime.c
dir.c
dl.c
dns.c
dns_win32.c
exec.c
file.c
filestat.c
filters.c
flock_compat.c
formatted_print.c
fsock.c
ftok.c
ftp_fopen_wrapper.c
head.c
hrtime.c
html.c
http.c
http_fopen_wrapper.c
image.c
incomplete_class.c
info.c
iptc.c
levenshtein.c
link.c
mail.c
math.c
md5.c
metaphone.c
microtime.c
net.c
pack.c
pageinfo.c
password.c
php_crypt_r.c
php_fopen_wrapper.c
proc_open.c
quot_print.c
scanf.c
sha1.c
soundex.c
streamsfuncs.c
string.c
strnatcmp.c
syslog.c
type.c
uniqid.c
url.c
url_scanner_ex.c
user_filters.c
uuencode.c
var.c
var_unserializer.c
versioning.c
avifinfo.c
        rc /nologo /fo F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS\php8ts.dll.res /d FILE_DESCRIPTION="\"PHP Script Interpreter\""  /d FILE_NAME="\"php8ts.dll\"" /d PRODUCT_NAME="\"PHP Script Interpreter\""  /IF:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS /d MC_INCLUDE="\"F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS\wsyslog.rc\""  win32\build\template.rc
        ML64.exe /DBOOST_CONTEXT_EXPORT=EXPORT /nologo /c /Fo F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS\Zend\jump_x86_64_ms_pe_masm.obj Zend\asm\jump_x86_64_ms_pe_masm.asm
 Assembling: Zend\asm\jump_x86_64_ms_pe_masm.asm
        ML64.exe /DBOOST_CONTEXT_EXPORT=EXPORT /nologo /c /Fo F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS\Zend\make_x86_64_ms_pe_masm.obj Zend\asm\make_x86_64_ms_pe_masm.asm
 Assembling: Zend\asm\make_x86_64_ms_pe_masm.asm
   Creating library F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS\php8ts.lib and object F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS\php8ts.exp
   Creating library F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS\php_vld.lib and object F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS\php_vld.exp
EXT vld build complete
php_cli.c
php_cli_process_title.c
php_cli_server.c
php_http_parser.c
ps_title.c
   Creating library F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS\php.lib and object F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS\php.exp
SAPI sapi\cli build complete

F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src

Done! output: F:\php-sdk\php-dev\vs16\x64\php-8.2.16-src\x64\Release_TS\php_vld.dll

Download:
VLD windows extension for PHP 8.2 vc15 x64 TS
VLD windows extension for PHP 8.2 vs16 x64 TS

Leave a Reply