Describe the bug
On Windows MSVC, installing libpq with x64-windows-static or
x86-windows-static triplets results in the DLL import library being
installed as lib/libpq.lib (42 KB) instead of the true static library.
The actual static archive libpq.a (2 MB) is built by meson but never
copied to the install tree, causing consumers to link dynamically against
libpq.dll at runtime and transitively load OpenSSL DLLs.
Environment
- OS: Windows
- Compiler: MSVC (Visual Studio 2022)
- vcpkg version: latest
To Reproduce
./vcpkg install libpq:x64-windows-static
- Link a consumer project against
libpq.lib
- Run the binary —
libpq.dll and libcrypto-3-x64.dll are loaded at runtime
Or verify directly:
dir %VCPKG_ROOT%\installed\x64-windows-static\lib\libpq*
→ libpq.lib is 42 KB (import library, not a static archive)
Expected behavior
installed/x64-windows-static/lib/libpq.lib should be the static archive
(~2 MB), built from libpq.a produced by the meson build.
No libpq.dll should be loaded at runtime.
Failure logs
The bug does not produce a build error. Evidence:
buildtrees/libpq/x64-windows-static-rel/src/interfaces/libpq/libpq.a — 2 MB ✅ (built but discarded)
installed/x64-windows-static/lib/libpq.lib — 42 KB ❌ (DLL import lib)
installed/x64-windows-static/bin/libpq.dll — absent (correctly removed)
- Consumer binary dynamically loads
libpq.dll and libcrypto-3-x64.dll at runtime
Additional context
Root cause is in ports/libpq/build-msvc.cmake.
The static build path removes bin/ but never installs libpq.a as lib/libpq.lib:
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
# libpq.a is built by meson but never copied here
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
Suggested fix — add before the REMOVE_RECURSE:
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(GLOB _static_libs
"${CURRENT_PACKAGES_DIR}/lib/libpq.a"
"${CURRENT_PACKAGES_DIR}/debug/lib/libpq.a"
)
foreach(_src IN LISTS _static_libs)
string(REPLACE ".a" ".lib" _dst "${_src}")
file(COPY_FILE "${_src}" "${_dst}")
file(REMOVE "${_src}")
endforeach()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
Note: the Unix/mingw path in portfile.cmake correctly handles
VCPKG_LIBRARY_LINKAGE via LIBPQ_LIBRARY_TYPE. The MSVC path
(build-msvc.cmake) lacks the equivalent handling.
Describe the bug
On Windows MSVC, installing
libpqwithx64-windows-staticorx86-windows-statictriplets results in the DLL import library beinginstalled as
lib/libpq.lib(42 KB) instead of the true static library.The actual static archive
libpq.a(2 MB) is built by meson but nevercopied to the install tree, causing consumers to link dynamically against
libpq.dllat runtime and transitively load OpenSSL DLLs.Environment
To Reproduce
./vcpkg install libpq:x64-windows-staticlibpq.liblibpq.dllandlibcrypto-3-x64.dllare loaded at runtimeOr verify directly:
→
libpq.libis 42 KB (import library, not a static archive)Expected behavior
installed/x64-windows-static/lib/libpq.libshould be the static archive(~2 MB), built from
libpq.aproduced by the meson build.No
libpq.dllshould be loaded at runtime.Failure logs
The bug does not produce a build error. Evidence:
buildtrees/libpq/x64-windows-static-rel/src/interfaces/libpq/libpq.a— 2 MB ✅ (built but discarded)installed/x64-windows-static/lib/libpq.lib— 42 KB ❌ (DLL import lib)installed/x64-windows-static/bin/libpq.dll— absent (correctly removed)libpq.dllandlibcrypto-3-x64.dllat runtimeAdditional context
Root cause is in
ports/libpq/build-msvc.cmake.The static build path removes
bin/but never installslibpq.aaslib/libpq.lib:Suggested fix — add before the
REMOVE_RECURSE:Note: the Unix/mingw path in
portfile.cmakecorrectly handlesVCPKG_LIBRARY_LINKAGEviaLIBPQ_LIBRARY_TYPE. The MSVC path(
build-msvc.cmake) lacks the equivalent handling.