Using Specified Lib Version in Vcpkg

Fatal disadvantage: no version management

However, strictly speaking, Vcpkg is not a complete solution. At least I don’t think so. It has a very fatal flaw- there is no function of version management. This shortcoming is very, very serious.

.\vcpkg install glm glfw3
.\vcpkg integrate install

Vcpkg a solution based on GIT version control

In order to find a solution, we must first understand how Vcpkg works. Vcpkg is a set of GIT based library management tools. It is more like that Microsoft manages a set of cloud library versions for you. What it cares about is not which version of the function library you want. Instead, Microsoft has been evolving these versions for its own way. He only cares whether they can work properly, not whether you can work normally. So once git pull then you may unwittingly update the version of a bunch of libraries to another version. As a result, your project may no longer work properly.

Solution 1: Use multiple Vcpkg

Since updating Vcpkg may cause potential problems, maintaining a specific version for specific projects will also reduce problems caused by conflicting versions. And this will not bring extra work, just waste more disk space.

Vcpkg checkout Tag
MyProject\
+- vcpkg
.\vcpkg integrate project
Package Manager Console
Install-Package vcpkg.C.vcpkg -Source "path\vcpkg\scripts\buildsystems"

Solution 2: Use independent nupkg installation package

You may notice that if all project uses the full Vcpkg, they will consume lots of disk space. For example, a C ++ Boost may have up to 10GB of space. You may only need a few small tools from the Boost library, but you have to pay a lot of space, which is really not good idea.

.\vcpkg export boost boost:x64-windows zlib --nuget
Install-Package vcpkg-export-20200417-005338 -Source "path of nupkg"

Conclusion:

Vcpkg is undoubtedly a powerful library management tool. But the lack of version management caused a lot of trouble. In fact, the multiple Vcpkg method can only solve part of the problem of multiple versions. For more complex versions, manual adjustments must be used. It is difficult to say whether it is worth it. In addition, Vcpkg fully supports the CMake function, which is also very important. Because there is no default library path in the Windows environment, for multiple CMake, find_package is needed, and it is almost impossible to find the corresponding package correctly. Using the CMake toolchain to set to Vcpkg has become a super convenient solution.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store