目录
包管理工具
当我们需要使用别人开发的库时,可能会需要去下载其源码然后编译再引入我们的项目,这样做的话一来引用的库多了比较麻烦,而且需要自己管理这些包,二来一旦迁移到其他机子上就得复制过去或是再下载编译一次,尤其对跨平台项目来说简直苦不堪言,因此会有包管理工具的出现。
vcpkg
它是由微软开发的,可以像安装普通软件一样地安装库,而且和visual studio/cmake很契合,在win和linux都可用。
安装
- 先找一个你希望安装vcpkg的位置,这里使用ubuntu示例,路径选在/home/coolight/app
- 打开控制台,来到上述路径,然后执行命令(需要先安装git,请忽略命令前的 $ ):
$ git clone https://github.com/microsoft/vcpkg
- 由于网络原因,可能会拉取失败,如果你能搭梯子最好,不能的话就多试几次或者换wifi/移动数据等尝试。
- 下载完成后在当前目录下就会有一个叫vcpkg的目录
- 进入vcpkg目录,注意它有两个文件:
- bootstrap-vcpkg.sh:linux系统请执行这个文件(执行命令 ./bootstrap-vcpkg.sh )
- bootstrap-vcpkg.bat:win系统请执行这个文件(双击打开或执行命令 bootstrap-vcpkg.bat)
- 执行完后就会出现上图中最后的那个vcpkg可执行文件,win系统下为vcpkg.exe。至此就安装完成了
- 当然目前只能在这个目录运行vcpkg来安装、升级等操作,设置环境变量即可在任意地方都可以运行。
常用命令
搜索库
- ./vcpkg search [库名]
- 搜索可安装的包,示例:
安装库
- ./vcpkg install [库名]:[位数-系统环境] [可选参数]
- 位数有x86和64;x86即32位,x64即64位。可以省略,win下默认安装32位,linux下默认安装64位。
- 系统环境可以是windows,linux等,可以省略,默认会安装当前系统环境对应的库,可以通过命令查看:./vcpkg help triplet
- win下默认会安装x86版本,而linux下默认是x64。可以设置环境变量修改这个默认安装的版本:
- VCPKG_DEFAULT_TRIPLET=x64-windows
- -
- 可选参数有很多,比如:
- --head,安装库的最新的版本
- --dry-run,不做任何实质上的下载安装,仅显示将要被安装的库的名称和版本信息
- ......
- 例如:
- 安装spdlog:./vcpkg install spdlog
- 安装openssl并指定安装win的64位:./vcpkg install openssl:x64-windows
- 可选参数有很多,比如:
卸载库
- ./vcpkg remove [库名]
- ./vcpkg remove --outdated 卸载所有过期的库
列出已安装库
- ./vcpkg list
集成到开发环境
- ./vcpkg integrate install
- 需要执行这一句才能“通知”到vs或是cmake使用这些安装的库
问题
如果使用vcpkg安装库,更新等过程中报错,请一定一定要耐心看它的错误信息,往往它会告诉你解决办法,比如因缺少依赖软件需要安装;因网络问题文件下载失败,需要重试等等。
安装库之后导入使用依然报错
- 可能你没有让vcpkg集成过去,需要执行:./vcpkg integrate install
- 如果使用的是cmake,安装后还需要在项目的CMakelist.txt配置相应的编译链接,这些一般在vcpkg安装库完成后会提示:
如何重装/卸载vcpkg
- 我一直是直接把整个vcpkg文件夹删了就是卸载了,然后重新走一次教程安装就是重装
ubuntu下安装ICU一直在最后出错
- 其实第一次出错的时候有提示说需要一个叫autoconf的程序但还没安装找不到
- 但我执行 sudo apt install autoconf 之后还是出错
- 后来根据vcpkg的提示去看了错误日志文件:[vcpkg root]/buildtrees/icu/config-x64-linux-dbg-err.log
- 里面就提示错误是因为找不到 autoconf-archive
- 因此执行sudo apt install autoconf-archive 安装上再运行vcpkg重新安装ICU就成功了
can i get generic clomid pill: how to get cheap clomid without a prescription – can i get cheap clomid tablets
I was extremely pleased to find this web site. I wanted to thank you for ones time due to this wonderful read!! I definitely really liked every little bit of it and I have you book marked to look at new information on your web site.
Great post! We will be linking to this great content on our site. Keep up the good writing.
Excellent post. I am experiencing a few of these issues as well..
amoxicillin 500 mg capsule: amoxicillin 500mg capsule buy online – buy amoxicillin 500mg uk
Everything is very open with a very clear clarification of the issues. It was really informative. Your website is very useful. Many thanks for sharing!
amoxicillin tablets in india: amoxicillin azithromycin – amoxicillin 500 mg price
An outstanding share! I’ve just forwarded this onto a colleague who has been conducting a little research on this. And he in fact bought me breakfast due to the fact that I stumbled upon it for him… lol. So let me reword this…. Thank YOU for the meal!! But yeah, thanx for spending some time to discuss this topic here on your internet site.
You are so awesome! I don’t suppose I’ve read through a single thing like this before. So good to discover someone with some genuine thoughts on this issue. Really.. many thanks for starting this up. This website is something that is needed on the internet, someone with a little originality.
Excellent blog you’ve got here.. It’s difficult to find high quality writing like yours nowadays. I really appreciate individuals like you! Take care!!
buy amoxicillin online with paypal: where can you buy amoxicillin over the counter – can you buy amoxicillin over the counter
Howdy! This article couldn’t be written any better! Looking through this post reminds me of my previous roommate! He constantly kept talking about this. I will send this information to him. Fairly certain he’ll have a good read. Thanks for sharing!
You ought to be a part of a contest for one of the greatest websites on the web. I’m going to highly recommend this site!
paxlovid price: Paxlovid buy online – paxlovid generic
You are so cool! I don’t believe I’ve truly read through anything like this before. So nice to discover another person with a few genuine thoughts on this topic. Really.. thank you for starting this up. This web site is something that’s needed on the internet, someone with a little originality.
Way cool! Some very valid points! I appreciate you penning this post and also the rest of the site is really good.
cheap doxycycline online uk: cheapest doxycycline online – doxycycline 100 mg cost generic
I really love your website.. Very nice colors & theme. Did you make this site yourself? Please reply back as I’m planning to create my very own site and want to know where you got this from or exactly what the theme is named. Many thanks!
п»їbest mexican online pharmacies: pharmacies in mexico that ship to usa – buying from online mexican pharmacy
I was more than happy to discover this site. I want to to thank you for ones time just for this fantastic read!! I definitely enjoyed every part of it and i also have you book-marked to check out new stuff on your site.
pharmacies in mexico that ship to usa: mexican online pharmacies prescription drugs – medication from mexico pharmacy
canadian pharmacy 24h com safe: reliable canadian pharmacy – canada drugs
mexico drug stores pharmacies: mexico pharmacy – mexican online pharmacies prescription drugs
mexico pharmacy purple pharmacy mexico price list buying prescription drugs in mexico
@Charlestaf buy ventolin: Buy Albuterol inhaler online – ventolin 2
ventolin 70
https://indiapharmast.com/# top 10 online pharmacy in india
You’ve provided a nuanced view on this topic.pbn 백링크
buying prescription drugs in mexico online mexican pharmaceuticals online mexican border pharmacies shipping to usa
I could not resist commenting. Perfectly written.
mexico drug stores pharmacies: mexican mail order pharmacies – mexican drugstore online
mexican border pharmacies shipping to usa pharmacies in mexico that ship to usa mexican pharmacy
indian pharmacies safe online shopping pharmacy india indian pharmacies safe
https://foruspharma.com/# buying from online mexican pharmacy
mexican rx online: reputable mexican pharmacies online – buying prescription drugs in mexico
Online medicine order: indian pharmacy online – reputable indian pharmacies
mexican border pharmacies shipping to usa buying prescription drugs in mexico online mexican border pharmacies shipping to usa
reputable indian pharmacies Online medicine home delivery cheapest online pharmacy india
https://indiapharmast.com/# world pharmacy india
canadian pharmacy: canadian valley pharmacy – online pharmacy canada
I need to to thank you for this great read!! I definitely enjoyed every little bit of it. I have you book-marked to check out new things you post…
Having read this I believed it was really informative. I appreciate you spending some time and effort to put this article together. I once again find myself spending a lot of time both reading and commenting. But so what, it was still worthwhile.
Greetings! Very helpful advice in this particular article! It’s the little changes that make the most important changes. Many thanks for sharing!
This is a great tip particularly to those new to the blogosphere. Simple but very accurate information… Thank you for sharing this one. A must read article!
Hi there! I simply wish to give you a big thumbs up for your excellent information you have got here on this post. I’ll be coming back to your website for more soon.
The very next time I read a blog, I hope that it won’t fail me as much as this one. After all, Yes, it was my choice to read through, nonetheless I actually believed you would probably have something helpful to say. All I hear is a bunch of complaining about something you can fix if you weren’t too busy seeking attention.
You’ve made some decent points there. I checked on the web for additional information about the issue and found most people will go along with your views on this website.
I came across this good from you out of sheer luck and never think lucky enough to say also credit you for any job well done.
I am usually to running a blog and i actually recognize your content. The article has really peaks my interest. I am going to bookmark your website and keep checking for new information.
Oh my goodness! an amazing article dude. Thanks a ton Nonetheless I will be experiencing problem with ur rss . Do not know why Not able to join it. Can there be everyone acquiring identical rss issue? Anybody who knows kindly respond. Thnkx
Simply desire to say your article is as surprising. The clearness in your post is just excellent and i can assume you’re an expert on this subject. Well with your permission allow me to grab your feed to keep updated with forthcoming post. Thanks a million and please carry on the rewarding work.
I wanted to thank you for this good read!! I absolutely loved every bit of it. I’ve got you book-marked to check out new stuff you post…