当前位置: 首页 > news >正文

在VS中通过vcpkg包管理器来安装使用qt5

常用指令

//安装最新版的库 .\vcpkg install 库名 //安装指定版本 .\vcpkg install 库名@版本号 //安装指定版本 .\vcpkg install 库名 --triplet x86-windows //或者 .\vcpkg install 库名:x86-windows .\vcpkg install 库名:x64-windows //查询已安装的所有库 .\vcpkg list //查询可以更新的库 .\vcpkg update //更新所有可以更新的库并删除旧版本 .\vcpkg upgrade --no-dry-run //更新opencascade到最新版本,并删除早期版本 .\vcpkg upgrade opencascade --triplet x86-windows --no-dry-run //查询是否存储的库 .\vcpkg search 库名 //导出所有库为7z格式 .\vcpkg export --x-all-installed --7zip //导出指定库为7z格式 .\vcpkg export 库名 --7zip //查询导出功能的帮助信息,其他功能类似 .\vcpkg help export //qt5常用库安装 .\vcpkg install qt5-base qt5-tools qt5-imageformats qt5-svg qt5-multimedia qt5-networkauth --recurse
PS G:\vcpkg> .\vcpkg help usage: vcpkg <command> [--switches] [--options=values] [arguments] @response_file @response_file Contains one argument per line expanded at that location Package Installation: export Creates a standalone deployment of installed ports install Installs a package remove Uninstalls a package x-set-installed Installs, upgrades, or removes packages such that that installed matches exactly those supplied upgrade Rebuilds all outdated packages Package Discovery: x-check-support Tests whether a port is supported without building it depend-info Displays a list of dependencies for ports list Lists installed libraries owns Searches for the owner of a file in installed packages x-package-info Display detailed information on packages portsdiff Diffs changes in port versions between commits search Searches for packages available to be built update Lists packages that can be upgraded Package Manipulation: add Adds dependency to manifest x-add-version Adds a version to the version database create Creates a new port edit Edits a port, optionally with %EDITOR%, defaults to "code" env Creates a clean shell environment for development or compiling format-manifest Prettyfies vcpkg.json hash Gets a file's SHA256 or SHA512 x-init-registry Creates a blank git registry new Creates a new manifest x-update-baseline Updates baselines of git registries in a manifest to those registries' HEAD commit Other: ci Tries building all ports for CI testing x-ci-verify-versions Checks integrity of the version database contact Displays contact information to send feedback fetch Fetches something from the system or the internet integrate Integrates vcpkg with machines, projects, or shells For More Help: help topics Displays full list of help topics help <topic> Displays specific help topic help commands Displays full list of commands, including rare ones not listed here help <command> Displays help detail for <command> For more help (including examples) see https://learn.microsoft.com/vcpkg

1.设置 vcpkg

  • 1.克隆存储库

  • vcpkg 概述 | Microsoft Learn
  • 从 GitHub 克隆 vcpkg 存储库。 存储库包含用于获取 vcpkg 可执行文件的脚本,以及由 vcpkg 社区维护的特选开放源代码库的注册表。 要执行此操作,请运行:

    控制台复制

    git clone https://github.com/microsoft/vcpkg.git

    vcpkg 特选注册表是一组数量超过 2000 个的开源库。 这些库已通过 vcpkg 的持续集成管道进行验证,可以协同工作。 虽然 vcpkg 存储库不包含这些库的源代码,但它保存方案和元数据,以便在系统中生成和安装它们。

  • 2.运行启动脚本

    现在,你已经克隆了 vcpkg 存储库,请导航到vcpkg目录并执行启动脚本:

    控制台复制

    cd vcpkg; .\bootstrap-vcpkg.bat

    启动脚本执行先决条件检查并下载 vcpkg 可执行文件。

    就这么简单! vcpkg 已安装并可供使用。

2.采用经典模式或者清单模式安装对应库

这里采用经典模式

通过powershell来调用vcpkg指令.

打开第一步设置的vcpkg仓库文件夹, 按住shift+右键, 调用powershell窗口.

输入

查看当前vcpkg中的库列表

.\vcpkg list

安装qt5 (最好开启网络代理,因为需要用到github中的库,所以国内的网络基本难搞)

默认64bit

.\vcpkg install qt5

32bit

.\vcpkg install qt5 --triplet x86-windows

等完成, 完成后也可以再次查看list中库

安装qt中的其他库

.\vcpkg install qt5-remoteobjects qt5-serialbus

等待完成.

整体的速度要比自己下载源代码快很多,1个多小时就可以搞定.

完成后可在vcpkg文件夹中看到如下文件夹

可以看到比原来多了4个文件夹,buildtrees,downloads,installed,packages.

buildtrees中是所有库的源代码.

installed所有库汇总的编译完成后,头文件,lib文件,dll文件都在这里.(主要用这个)

packages编译完后的独立的头文件头文件,lib文件,dll文件都在这里.

在vs中采用qt-addin插件来编写qt时,需要将debug中生成的qt相关的lib文件(后面都带个d的文件)放置到release的lib路径下才能正常调试debug, 可能因为插件的关系.(cmake方式编译可能不需要,未验证)

debug下的qt所有lib文件复制到release下的lib文件夹

3.将qt-Addin插件中的qt版本设置为vcpkg中版本

将qmake路径设置为G:\vcpkg\installed\x64-windows\tools\qt5

这里路径根据自己电脑的设置设置<vcpkg路径>\installed\x64-windows\tools\qt5

4.将vcpkg包管理设置到项目中

1.在vcpkg安装目录下, 按2步中开启powershell的方式开启

输入如下指令,生成一个nuget包源文件

.\vcpkg integrate project

2.在VS中设置,通过nuget增加一个包源

路径设置为vcpkg的安装路径

3.安装vcpkg包到当前的解决方案中

4.在工程项目-属性-vcpkg中设置

根据当前配置设置对应vcpkg版本,这里只用了经典模式,所以不要选清单开启.

基本完成,省去了头文件,lib,dll的相关设置了.

vcpkg会直接将用的所有dll直接copy到exe文件路径下.方便很多了, 比windeployqt的方式要方便.

5.将当前电脑中的库文件导出到另外一台电脑中

1.在vcpkg仓库目录下,调用powershell窗口,

输入

.\vcpkg export --x-all-installed --zip

将所有的库文件打包为zip文件, 将把installed中的所有库打包为zip文件

2.将打包好的zip文件复制到新电脑中

在新电脑中也同样按步骤1创建vcpkg仓库,然后将解压后的文件放置到vcpkg目录下即可

installed文件夹及scripts文件夹.

由于没有package文件夹,所以通过 list查看当前仓库列表,里面是空的,但是好像也不影响vcpkg的功能.

在VS按2,3,4步骤重新在新电脑设置即可.

http://www.jsqmd.com/news/1167242/

相关文章:

  • 大气层系统Atmosphere:Nintendo Switch定制固件终极安装指南
  • 2026年7月泉州惠普售后维修权益与质保政策解读|在保过保全知道.txt - 品牌引荐
  • AMD-Quark量化工具实战:一键将Qwen3.5模型压缩至MXFP4格式的完整脚本
  • PsychEngine终极指南:3步掌握FNF音乐节奏游戏创作
  • 思源宋体CN:7种字重完全免费,打造专业中文排版新体验
  • (1)uuuu
  • CANN/cannbot-skills: HFusion→HIVM 转换规则
  • Copilot Chat提示工程进阶,深度解析GPT-4o上下文理解机制与12类精准指令设计法
  • 三相异步电机三角形改星形误接线致绕组烧毁及保护拒动故障分析
  • CAD显示工具栏、显示背景方格网
  • Beyond Compare 5密钥生成器:双模式激活解决方案详解
  • WaveTools:终极鸣潮游戏性能优化工具箱完整指南
  • embed python环境快速搭建
  • Docker 构建 ARM64 镜像并导出二进制文件 — 完整操作指南
  • Flutter Android 无线调试No supported devices connected
  • ChatGPT-Image2图像生成实战:从免费使用到工作流搭建
  • 终极游戏库管理指南:5分钟掌握Playnite开源游戏管理器
  • MidiEditor:开源MIDI编辑器的完整功能架构解析
  • 性能对比分析:NV-Raw2insights-MRI在CMRxRecon挑战赛中的优异表现
  • 无锡2026全屋定制爱格可丽芙双授权品牌选购宝典 - 设计本
  • Llama-3.1-8B-Instruct-FP8-KV-Quark-test性能优化:KV缓存量化实战指南
  • 【ChatGPT JSON工程化实战】:从Prompt设计→Schema约束→反序列化熔断,构建零崩溃JSON流水线(含GitHub Star 4.2k的开源工具链)
  • SSM框架+MySQL 8.0 网上书店系统:3层架构设计与5大核心模块实现
  • Copilot Chat从入门到精通:3天掌握企业级AI协作工作流,附实测效率提升数据
  • 2026年7月泉州惠普售后专业维修服务中心综合指南|地址电话服务项目维保流程全攻略.txt - 品牌引荐
  • 2026年7月泉州华硕售后本地化服务全景|交通指引气候养护到店全攻略.txt - 品牌引荐
  • 如何在Windows上免费获得苹果级别中文排版体验:PingFangSC字体包完整指南
  • 终极指南:Nintendo Switch Cleaner and Builder 一站式游戏文件管理解决方案
  • LLM 幻觉检测:用输出一致性检查降低业务风险,别让模型在关键场景胡编
  • CANN Runtime日志配置查看