Skip to content

Get MSVC dependencies from a vcpkg manifest - #439

Merged
evanmiller merged 1 commit into
WizardMac:devfrom
hpoettker:vcpkg-msbuild-integration
Nov 19, 2026
Merged

evanmiller merged 1 commit into
WizardMac:devfrom
hpoettker:vcpkg-msbuild-integration

Conversation

@hpoettker

Copy link
Copy Markdown
Contributor

Why

The Windows MSVC build is seemingly flaky at the moment. The root cause is that zlib renamed its library file names for MSVC in the 1.4 release. And the build now fails on runners with a more recent vcpkg setup with zlib 1.4, and succeeds on runners with an older vcpkg setup.

The build currently works through a workflow step that copies libraries to the names the Visual Studio project expects. This step would need changes to reflect the zlib upgrade. And the project contains hard-coded paths such as C:\vcpkg\... and ..\..\..\iconv\lib64, which only works on particular setups.

Instead of adjusting the file copy step, I think it's a better idea to fully switch to a vcpkg setup also in the VS project itself. This also provides a much better developer experience as the project now automatically handles the dependencies. I tested this in the Visual Studio 2026 Community Edition, and I think creating a working setup for ReadStat on Windows is much simpler with this change.

The fixed vcpkg version has the benefit that the build is more reproducible and no longer fails on changes like in zlib 1.4. But it comes at the cost that the baseline should be actively bumped from time to time. I've added a section to the README how this works.

What

  • Add a vcpkg.json manifest at the repository root that lists libiconv and zlib. A pinned baseline keeps the library versions the same for local and CI builds. Optional csv and xlsx features cover the extra command-line tool features.
  • Remove the hard-coded library names and paths from the Visual Studio projects. vcpkg now supplies headers, import libraries and DLLs.
  • In CI, use the manifest instead of the renaming step, build release dependencies only, and cache them based on vcpkg.json.
  • Update the README's Windows section.

Testing

I built all four configurations (Debug/Release × Win32/x64) in Visual Studio 2026 Community, and the tests pass.

zlib 1.4 renamed its MSVC import library to libz.lib, which broke the
hard-coded zlib.lib references in the Visual Studio projects.

Add a vcpkg.json manifest (libiconv, zlib; optional features csv and
xlsx) with a pinned builtin-baseline, enable manifest mode in
PropertySheet.props, and drop the hard-coded library names and paths
from the projects. The vcpkg MSBuild integration now provides headers,
import libraries and DLLs.

In CI, check out the runner's vcpkg at the manifest baseline, build
only release dependencies, and key the binary cache on vcpkg.json; the
library renaming step is no longer needed.

Also run ReadStat_Test_readstat from the repository root in Visual
Studio, since the tests open resources/* relative to the working
directory.
@evanmiller
evanmiller merged commit 9b0804e into WizardMac:dev Nov 19, 2026
14 checks passed
@hpoettker
hpoettker deleted the vcpkg-msbuild-integration branch November 19, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants