Skip to content

CURL_STATICLIB flag set even if linked with shared lib #17855

Closed
@nono303

Description

@nono303

Description

Looking at https://github.com/php/php-src/blob/master/ext/curl/config.w32#L18 when compiling ext/curl on Windows, CFLAG CURL_STATICLIB is set event if linked with shared libcurl.
I don’t know the extent of the impact but it might be interesting to set it only when it’s built against static libcurl.
My working patch (which can definitely be improved)

diff --git a/ext/curl/config.w32 b/ext/curl/config.w32
index 82be5212e5..14ac3ffca1 100644
--- a/ext/curl/config.w32
+++ b/ext/curl/config.w32
@@ -27,7 +27,10 @@ if (PHP_CURL != "no") {
 		) {
 		EXTENSION("curl", "interface.c multi.c share.c curl_file.c");
 		AC_DEFINE('HAVE_CURL', 1, "Define to 1 if the PHP extension 'curl' is available.");
-		ADD_FLAG("CFLAGS_CURL", "/D CURL_STATICLIB /D PHP_CURL_EXPORTS=1");
+		ADD_FLAG("CFLAGS_CURL", "/D PHP_CURL_EXPORTS=1");
+		if (CHECK_LIB("libcurl_a.lib", "curl", PHP_CURL)){
+			ADD_FLAG("CFLAGS_CURL", "/D CURL_STATICLIB");
+		}
 		PHP_INSTALL_HEADERS("ext/curl", "php_curl.h");
 	} else {
 		WARNING("curl not enabled; libraries and headers not found");

PHP Version

PHP 8.4.4

Operating System

Windows 11 - MSVC x64 build

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions