[INTERNALS-WIN] MSVC linker error LNK2001: unresolved external symbol "void * _tsrm_ls_cache"

From: Date: Wed, 04 Dec 2024 16:00:33 +0000
Subject: [INTERNALS-WIN] MSVC linker error LNK2001: unresolved external symbol "void * _tsrm_ls_cache"
Groups: php.internals.win 
Request: Send a blank email to internals-win+get-1314@lists.php.net to get a copy of this message
Hi team, I request your help in debugging a PHP extension compilation failure on Windows with MSVC that seems to be related to ZTS/TSRM and environment setup. I've earlier raised this GitHub issue on php-src: Windows: MSVC linker error LNK2001: unresolved external symbol "void * _tsrm_ls_cache" - when building PHP extension<https://github.com/php/php-src/issues/17018>. The compilation of our extension (CMake is used) with ZTS enabled is failing with below linker errors: [build] Creating library C:/abc.lib and object C:/abc.exp [build] file1.cpp.obj : error LNK2001: unresolved external symbol "void * _tsrm_ls_cache" (?_tsrm_ls_cache@@3PEAXEA) [C:\workspace\abc.vcxproj] [build] file2.obj : error LNK2001: unresolved external symbol "void * _tsrm_ls_cache" (?_tsrm_ls_cache@@3PEAXEA) [C:\workspace\abc.vcxproj] We are using these flags on Windows when building our extension: _CRT_SECURE_NO_WARNINGS NOMINMAX PHP_WIN32=1 ZEND_WIN32=1 ZTS=1 # ZTS may not always be on, but main\config.w32.h doesn't seem to carry it unlike main/php_config.h on Linux ZEND_ENABLE_STATIC_TSRMLS_CACHE=1 Am I not setting some macro definition required for Windows or something thing I missed when building PHP runtime. I build PHP using the following configure command on the same machine: configure --disable-phpdbg --enable-intl --enable-mbstring --enable-opcache --enable-pdo --enable-soap --enable-sockets --with-curl --with-mysqli --with-openssl --with-pdo-mysql --with-pdo-sqlite --with-sqlite3 --enable-fileinfo --enable-embed --enable-zts We use the TSRM macros ZEND_TSRMLS_CACHE_DEFINE(). ZEND_TSRMLS_CACHE_EXTERN() and ZEND_TSRMLS_CACHE_UPDATE() the usual way that most internal PHP extensions do i.e., call the EXTERN macro in php_extension.h and the UPDATE macro in GINIT of our extension, only when ZTS macro is defined. Could you please help me resolve this linker issue. Here are some build environment details: PHP version: PS > php -v PHP 8.3.12-dev (cli) (built: Dec 2 2024 17:43:09) (ZTS Visual C++ 2019 x64) Copyright (c) The PHP Group Zend Engine v4.3.12-dev, Copyright (c) Zend Technologies PHP SDK & MSVC version PHP SDK 2.3.0 ARCH x64 Visual C++: 14.29.30156.0 Thanks in advance! Best regards Sankara Jayanth

« previous php.internals.win (#1314) next »