草庐IT

vcpkg 安装任意版本的开源库

poinsettia 2024-01-13 原文

为表述方便,本文全以openssl为例。

常规安装

前面已经写过vcpkg的简明教程:https://blog.csdn.net/poinsettia/article/details/127885576

只要执行以下几行命令,就可以安装好openssl

git clone https://github.com/Microsoft/vcpkg.git # install vcpkg
./vcpkg\bootstrap-vcpkg.bat # build vcpkg.exe
./vcpkg install openssl:x64-windows # install opensl

但是这样有个问题是,这样只能安装默认版本的openssl,无法指定具体的openssl。

注:openssl的版本定义在ports文件夹中的vcpkg.json中

Example

{
  "name": "openssl",
  "version-string": "1.1.1n",
  "description": "OpenSSL is an open source project that provides a robust, commercial-grade, and full-featured toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols. It is also a general-purpose cryptography library.",
  "homepage": "https://www.openssl.org",
  "license": "OpenSSL",
  "dependencies": [
    {
      "name": "vcpkg-cmake",
      "host": true
    },
    {
      "name": "vcpkg-cmake-config",
      "host": true
    }
  ]
}

那如何安装自己想要的版本呢? 比如目前vcpkg的默认版本(其实是最新版本)是3.0.7,我想安装1.1.1n 怎么办呢?

安装任意版本

Refer:https://stackoverflow.com/questions/53805917/install-older-version-of-protobuf-via-vcpkg

The selected answer

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 openssl

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

大意就是根据git log 找到openssl1.1.1n 对应的vcpkg的git 节点,把vcpkg git repo reset到对应节点,然后就可以install 1.1.1n版本啦。

那如果版本在vcpkg找不到呢? 比如 openssl1.1.1q

利用vcpkg build自己想要的包

refer:https://vcpkg.io/en/docs/examples/packaging-zipfiles.html

文中的方法麻烦的点是在于要自己写portfile.cmake, 为了简单起见,我直接利用了openssl1.1.1n的工程进行改造。具体过程如下:

  1. 利用git log找到升级openssl1.1.1n的节点

  2. git show 查看具体提交了什么内容

  3. 仿照git show提交的内容,把1.1.1n版本改为1.1.1q版本。

    我是借助TortoiseSVN 工具,可以更方便看到修改的文件。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-CFt4blZy-1668671164163)(windows openssl 出包.assets/image-20221117154016692.png)]

遇到的最主要问题就是hash值校验,这个问题也可以很方便解决,因为在install 的时候会给出提示,提示中有正确的hash,直接复制过去即可。

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cV9iUKyX-1668671164164)(windows openssl 出包.assets/image-20221117154407120.png)]

  1. install ./vcpkg install openssl:x64-windows

有关vcpkg 安装任意版本的开源库的更多相关文章

  1. ruby - 如何从 ruby​​ 中的字符串运行任意对象方法? - 2

    总的来说,我对ruby​​还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用

  2. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

  3. ruby - 完全离线安装RVM - 2

    我打算为ruby​​脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn

  4. ruby-on-rails - rails 目前在重启后没有安装 - 2

    我有一个奇怪的问题:我在rvm上安装了ruby​​onrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(

  5. ruby - 如何为 emacs 安装 ruby​​-mode - 2

    我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby​​提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs

  6. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  7. ruby - 通过 RVM (OSX Mountain Lion) 安装 Ruby 2.0.0-p247 时遇到问题 - 2

    我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search

  8. ruby-on-rails - 项目升级后 Pow 不会更改 ruby​​ 版本 - 2

    我在我的Rails项目中使用Pow和powifygem。现在我尝试升级我的ruby​​版本(从1.9.3到2.0.0,我使用RVM)当我切换ruby​​版本、安装所有gem依赖项时,我通过运行railss并访问localhost:3000确保该应用程序正常运行以前,我通过使用pow访问http://my_app.dev来浏览我的应用程序。升级后,由于错误Bundler::RubyVersionMismatch:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0,此url不起作用我尝试过的:重新创建pow应用程序重启pow服务器更新战俘

  9. ruby - 如何在 Lion 上安装 Xcode 4.6,需要用 RVM 升级 ruby - 2

    我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121

  10. ruby - Fast-stemmer 安装问题 - 2

    由于fast-stemmer的问题,我很难安装我想要的任何ruby​​gem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=

随机推荐