Compiling ZMQ for PHP 8 NTS in Windows Server(IIS)

Hello,
Since compiling ZMQ for PHP 8 NTS in Windows Server(IIS) were never fully documented I’d like to share how I managed to do this.

  1. Download and install Visual Studio Build Tools 2019
    Create a network-based installation - Visual Studio (Windows) | Microsoft Learn
    https://aka.ms/vs/16/release/vs_buildtools.exe


  2. Download and extract Tool kit for building PHP under Windows
    GitHub - microsoft/php-sdk-binary-tools: Tool kit for building PHP under Windows
    https://github.com/microsoft/php-sdk-binary-tools/archive/refs/heads/master.zip

  3. Download and extract source code of PHP 8
    PHP For Windows: Binaries and sources Releases
    image

  4. Download and extract Source code (zip) of php-zmq
    Release zmq 4.3.4 - prebuilt Windows php extension binaries · stijnvdb88/php-zmq · GitHub

  5. Download and extract lib-zmq 4.3.4
    libzmq-v142-x64-4_3_4.zip
    Releases · zeromq/libzmq · GitHub

  6. Run Developer Command Prompt for VS 2019

  7. Change directory to \php-sdk-binary-tools-master\

  8. Run phpsdk-vs16-x64
    image

  9. Execute phpsdk_buildtree phpdev

  10. Copy PHP source code directory to \php-sdk-binary-tools-master\phpdev\vs16\x64\

  11. Copy php-zmq-4.3.4 (step 4.) to \php-sdk-binary-tools-master\phpdev\vs16\x64\php-8.2.21-src\ext\ and rename to zmq

  12. Edit \php-sdk-binary-tools-master\phpdev\vs16\x64\php-8.2.21-src\ext\zmq\config.w32 file by adding true as third parameter in EXTENSION function

  13. Copy zmq.h from lib-zmq 4.3.4 (step 5.) to \php-sdk-binary-tools-master\phpdev\vs16\x64\deps\include\

  14. Copy libzmq-v142-mt-4_3_4.lib from lib-zmq 4.3.4 (step 5.) to \php-sdk-binary-tools-master\phpdev\vs16\x64\deps\lib\ and rename to libzmq.lib

  15. Go back to Developer Command Prompt for VS 2019 console and change directory to \php-sdk-binary-tools-master\phpdev\vs16\x64\php-8.2.21-src\

  16. Execute buildconf --force
    image

  17. Execute configure --disable-all --disable-zts --enable-cli --with-zmq


    Verify if zmq.h and libzmq.lib were loaded and if zmq is visible in Enabled extensions.

  18. Execute nmake

  19. Go to \php-sdk-binary-tools-master\phpdev\vs16\x64\php-8.2.21-src\x64\Release\ and there you have php.zmq.dll

  20. Copy libzmq-v142-mt-4_3_4.dll from lib-zmq 4.3.4 (step 5.) to <your PHP directory>\ and php.zmq.dll to <your PHP directory>\ext\

1 Like