7

I installed protobuf via vcpkg vcpkg install protobuf:x64-windows. Apparently it installs the latest version (3.6.1). For the project I need version<=3.5.1. Is there any way to install it using vcpkg? For now I just built 3.5.1 using cmake but project looking for protobuf using path to vcpkg and I don't really know if I'm allowed to change the code.

Edwin Paco
  • 121
  • 2
  • 7
  • 2
    Ok, for those who encountered with same issue you can solve it by using checkout to the working commit of vcpkg with necessary protobuf. – Edwin Paco Jan 26 '19 at 19:18

2 Answers2

5

To have a specific version of a package in vcpkg, you need to checkout at the appropriate point in time in the vcpk repo.

  1. Go to your git installed vcpk folder.

  2. Identify the commit matching the version of protobuf you're looking for.

The following line color-codes the commit history to make it more readable and pipe it with grep to identify protobuf related commits.

git log --color=always --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad)' --date=short | grep --color=never protobuf

You'll find a line like b1fea4588 - [protobuf] update to 3.5.1 (2018-01-31). (The commit hash/message may have changed if the history has been rewritten.)

  1. Checkout the commit of interest : git checkout b1fea4588

  2. Run vcpkg install protobuf

The issue of package version management is very active on vcpkg repo. Check Issue #3592

amiabl
  • 1,047
  • 19
  • 27
-1

Use a new feature (June 2019): ports overlay https://github.com/microsoft/vcpkg/blob/master/docs/specifications/ports-overlay.md

Here is an example. The version of packet is hardcoded in file:

<VCPKG_ROOT>/ports/<packet_name>/CONTROL

Thus it's bound to the commit of vckpg. But you can override packet version with the following command

vcpkg --overlay-ports="/some/path/to/the_versions" install protobuf:x64-windows

The directory should contain packet specs:

/some/path/to/the_versions/protobuf/CONTROL
/some/path/to/the_versions/<packet_2_name>/CONTROL
/some/path/to/the_versions/<packet_3_name>/CONTROL

Usually, I just copy packet specs from the commit I was initially developing my project for. Hope this helps!

DarkSidds
  • 164
  • 11