Skip to content

ext/uri: Fix static build on Windows by defining LEXBOR_STATIC#22165

Open
luthermonson wants to merge 1 commit into
php:PHP-8.5from
luthermonson:fix/uri-lexbor-static-windows
Open

ext/uri: Fix static build on Windows by defining LEXBOR_STATIC#22165
luthermonson wants to merge 1 commit into
php:PHP-8.5from
luthermonson:fix/uri-lexbor-static-windows

Conversation

@luthermonson
Copy link
Copy Markdown

@luthermonson luthermonson commented May 28, 2026

Summary

ext/uri is always built statically and pulls in the bundled lexbor headers via /I ext/lexbor. On Windows, lexbor's LXB_API macro defaults to __declspec(dllimport) when LEXBOR_STATIC isn't defined. As a result, when PHP itself is linked statically (no DLL) on Windows, every lxb_* symbol referenced from ext/uri fails to resolve:

libphp.lib(php_uri.obj) : error LNK2019: unresolved external symbol
    __imp_lxb_url_parse referenced in function ...
... (one LNK2019 per lxb_* function reachable from ext/uri) ...

ext/uri is always built statically (false /* never shared */ in
EXTENSION()) and includes the bundled lexbor headers via
/I ext/lexbor. On Windows, lexbor's LXB_API macro defaults to
__declspec(dllimport) when LEXBOR_STATIC is not defined, producing
LNK2019 unresolved external symbol errors for every lxb_* function
referenced from ext/uri when linking PHP statically.

Add /D LEXBOR_STATIC to CFLAGS_URI next to the existing
URI_STATIC_BUILD flag, which serves the analogous role for ext/uri's
own API decoration.

This matches how ext/uri already handles its own static-linkage with
URI_STATIC_BUILD - the lexbor side was simply missing.
@luthermonson luthermonson changed the title Fix static ext/uri build on Windows by defining LEXBOR_STATIC ext/uri: Fix static build on Windows by defining LEXBOR_STATIC May 28, 2026
@TimWolla
Copy link
Copy Markdown
Member

I know nothing about Windows. Should / Must this be fixed in ext/lexbor instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants