日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

vcpkg下载mysql库_VCpkg 开源库管理工具

發(fā)布時(shí)間:2023/12/31 数据库 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vcpkg下载mysql库_VCpkg 开源库管理工具 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

VcPkg & MinGW GCC

VCpkg 開(kāi)源庫(kù)管理工具

Windows 下開(kāi)發(fā) C/C++ 程序,少不了編譯開(kāi)源的第三方庫(kù)。比如用于網(wǎng)絡(luò)連接的高性能庫(kù) libcurl、用于壓縮解壓的 zlib 等等。使用這些庫(kù)開(kāi)發(fā)極大的方便了程序員,使得我們不必重復(fù)造輪子。由于這些開(kāi)源庫(kù)絕大部分都來(lái)源于 Linux 系統(tǒng),其工程文件、編譯系統(tǒng)都使用 gnu 系列工具,使得將其移植到 Windows 的 VC 開(kāi)發(fā)環(huán)境下一直是難點(diǎn)。

還需要考慮預(yù)先編譯出哪種類型的開(kāi)源庫(kù)程序,比如:Debug 還是 Release、動(dòng)態(tài)庫(kù)還是靜態(tài)庫(kù)、MD 還是 MT、32 位還是 64 位。光是這三種組合就有 16 種可能性。如果像 libcurl 這種還要考慮是否引用其他開(kāi)源庫(kù)的功能,那么編譯類型的組合會(huì)更多。

VCpkg 就是解決這個(gè)問(wèn)題的:

自動(dòng)調(diào)用 git 等工具下載開(kāi)源庫(kù)源代碼;

源碼包的緩存管理和版本管理,可以升級(jí)版本;

緊密結(jié)合 CMake 輕松編譯;

依賴關(guān)系檢查,比如編譯 libcurl,會(huì)自動(dòng)下載 zlib、openssl 進(jìn)行編譯;

無(wú)縫集成 Visual Studio,不需要設(shè)置庫(kù)文件、頭文件的所在目錄,自動(dòng)集成。

Visual Studio 全平臺(tái)支持,支持 Debug/Release、x86/x64 編譯,還支持 UWP、ARM 平臺(tái)的編譯。

一般使用流程:

執(zhí)行 vcpkg 安裝模塊,等待編譯動(dòng)作完成;

執(zhí)行 vcpkg integrate 集成到項(xiàng)目或者 Visual Studio,又或者全局集成;

在代碼中通過(guò)頭文件使用安裝好的模塊;

vcpkg 主目錄文件夾結(jié)構(gòu):

| buildtrees | 所有下載好的 library 源代碼和構(gòu)建目錄 |

| docs | 文檔與示例 |

| downloads | 下載緩沖文件夾,執(zhí)行安裝命令時(shí)會(huì)先查詢這里 |

| installed | 包含安裝好的 library 頭文件和編譯文件 |

| packages | 內(nèi)部文件夾,在安裝時(shí)用到 |

| ports | 包含分類中的庫(kù)描述文件,包含版本、下載地址等 |

| scripts | 腳本目錄,如 cmake, powershell 腳本 |

| toolsrc | VcPkg C++ 源代碼和組件 |

| triplets | 包含支持架構(gòu)配置文件,如 x86-windows、x64-uwp |

vcpkg 安裝依賴模塊的基本執(zhí)行流程:

環(huán)境初始化

下載源代碼,如果已經(jīng)在 cache 中,則跳過(guò)下載環(huán)節(jié)

校驗(yàn)文件有效性

解壓縮源代碼

利用配套工具配置源碼工程,如 cmake,如果是 ffmpeg 則用 msys2

執(zhí)行 MSBuild 編譯源碼,一般會(huì)同時(shí)編譯 Release 和 Debug 版本。

把編譯好的文件拷貝到相關(guān)目錄中去,一般是 installed 目錄

如果沒(méi)有在 vcpkg 主目錄運(yùn)行,可能會(huì)遇到 Error: Could not detect vcpkg-root。

使用 PowerShell 執(zhí)行 Vcpkg 工程目錄下的 bootstrap-vcpkg.bat 進(jìn)行編譯,會(huì)在同級(jí)目錄下生成 vcpkg.exe 文件。

命令使用示范:

>vcpkg --help

Commands:

vcpkg search [pat] Search for packages available to be built

vcpkg install ... Install a package

vcpkg remove ... Uninstall a package

vcpkg remove --outdated Uninstall all out-of-date packages

vcpkg list List installed packages

vcpkg update Display list of packages for updating

vcpkg upgrade Rebuild all outdated packages

vcpkg x-history (Experimental) Shows the history of CONTROL versions of a package

vcpkg hash [alg] Hash a file by specific algorithm, default SHA512

vcpkg help topics Display the list of help topics

vcpkg help Display help for a specific topic

vcpkg integrate install Make installed packages available user-wide. Requires admin

privileges on first use

vcpkg integrate remove Remove user-wide integration

vcpkg integrate project Generate a referencing nuget package for individual VS project use

vcpkg integrate powershell Enable PowerShell tab-completion

vcpkg export ... [opt]... Exports a package

vcpkg edit Open up a port for editing (uses %EDITOR%, default 'code')

vcpkg import Import a pre-built library

vcpkg create [archivename]

Create a new package

vcpkg owns Search for files in installed packages

vcpkg depend-info ... Display a list of dependencies for packages

vcpkg env Creates a clean shell environment for development or compiling

vcpkg version Display version information

vcpkg contact Display contact information to send feedback

...

>vcpkg search assimp

>vcpkg search | findstr assimp

assimp 5.0.1 The Open Asset import library

magnum-plugins[assimpimporter] AssimpImporter plugin

>vcpkg search | findstr glu

aws-sdk-cpp[glue] C++ SDK for the AWS glue service

freeglut 3.2.1-4 Open source implementation of GLUT with source and binary backwards compatibil...

glui 2019-11-30 GLUI is a GLUT-based C++ user interface library

mathgl[glut] glut module

>vcpkg install assimp:

Computing installation plan...

The following packages will be built and installed:

assimp[core]:x86-windows

* minizip[core]:x86-windows

* rapidjson[core]:x86-windows

* zlib[core]:x86-windows

Additional packages (*) will be modified to complete this operation.

Warning: The following VS instances are excluded because the English language pack is unavailable.

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community

Please install the English language pack.

安裝具有 Cuda 加速的 opencv 庫(kù):

vcpkg search opencv

vcpkg install opencv[cuda]:x64-windows

vcpkg --triplet x64-windows install opencv[cuda]

支持的架構(gòu)組合查詢:

>vcpkg help triplet

VCPKG built-in triplets

VCPKG community triplets

arm-uwp

arm-ios

arm64-windows

arm-mingw

x64-linux

arm-windows

x64-osx

arm64-ios

x64-uwp

arm64-mingw

x64-windows-static

arm64-uwp

x64-windows

arm64-windows-static

x86-windows

wasm32-emscripten

x64-ios

x64-mingw

x64-osx-dynamic

x64-windows-static-md

x86-ios

x86-mingw

x86-uwp

x86-windows-static-md

x86-windows-static

作為 MinGW 的用戶,我非愿意看到 triplet 列表中有 x64-mingw 和 x86-mingw 的身影。

可以設(shè)置默認(rèn)的架構(gòu):

VCPKG_DEFAULT_TRIPLET=x64-windows

vcpkg 的 Triplet files 是用來(lái)記錄和庫(kù)相關(guān)的 OS、CPU、Compiler、Runtime 等信息的文件,它包含了編譯模塊時(shí)使用的工具鏈。

安裝第三方的 MinGW 架構(gòu)依賴庫(kù)時(shí)出現(xiàn)錯(cuò)誤:

>vcpkg install assimp:x64-mingw

Computing installation plan...

The following packages will be built and installed:

assimp[core]:x64-mingw

* minizip[core]:x64-mingw

* rapidjson[core]:x64-mingw

* zlib[core]:x64-mingw

Additional packages (*) will be modified to complete this operation.

Unable to determine toolchain to use for triplet x64-mingw with CMAKE_SYSTEM_NAME MinGW

提示信息表明,vcpkg 無(wú)法從 CMAKE_SYSTEM_NAME 指定的 x64-mingw 架構(gòu)確定需要用到的工具鏈:

triplets/community/x64-mingw.cmake

這個(gè)問(wèn)題有點(diǎn)惡心,因?yàn)?vcpkg 的源代碼忽略了 MinGW,解決方法是修改 build.cpp 重新編譯 vcpkg:

diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp

index c61c6b7..d7c78aa 100644

--- a/toolsrc/src/vcpkg/build.cpp

+++ b/toolsrc/src/vcpkg/build.cpp

@@ -558,6 +558,10 @@ namespace vcpkg::Build

else if (cmake_system_name == "Android")

{

return m_paths.scripts / fs::u8path("toolchains/android.cmake");

+ }

+ else if (cmake_system_name == "MinGW")

+ {

+ return m_paths.scripts / fs::u8path("toolchains/mingw.cmake");

}

else if (cmake_system_name.empty() || cmake_system_name == "Windows" || cmake_system_name == "WindowsStore")

{

--

安裝好依賴模塊后,接著是將 vcpkg 集成到項(xiàng)目或進(jìn)行全局集成:

>vcpkg integrate install

Applied user-wide integration for this vcpkg root.

All MSBuild C++ projects can now #include any installed libraries.

Linking will be handled automatically.

Installing new libraries will make them instantly available.

CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"

使用 CMake 的編譯項(xiàng)目中使用 vcpkg 安裝的庫(kù),最佳方式指定 CMake (Toolchain File) 工具鏈文件 scripts/buildsystems/vcpkg.cmake,讓 find_package() 命令發(fā)現(xiàn)安裝的庫(kù)。

要使用這個(gè)文件,通過(guò)命令參數(shù)傳入 CMake 即可:

cmake .. -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake (Linux/MacOS)

cmake .. -DCMAKE_TOOLCHAIN_FILE=vcpkg\scripts\buildsystems\vcpkg.cmake (Windows)

再比如,如果要用 VS2017 編譯器,輸入下面命令即可:

cmake .. -DCMAKE_TOOLCHAIN_FILE=D:\vcpkg\scripts\buildsystems\vcpkg.cmake -G "Visual Studio 15 2017 Win64"

還有一種方法,直接在 CMakeLists.txt 文件中指定 CMAKE_TOOLCHAIN_FILE 變量,即:

set(CMAKE_TOOLCHAIN_FILE "D:\vcpkg\scripts\buildsystems\vcpkg.cmake")

project(PROJECT_NAME)

注意,要在 project() 命令之前設(shè)置。另外,類似 CMAKE_SYSTEM_NAME,CMAKE_C_COMPILER 等這些變量都要在 project()命令之前設(shè)定,不然 CMake 會(huì)按照默認(rèn)的設(shè)置處理。

如果電腦中沒(méi)有安裝 cmake,vcpkg 會(huì)自動(dòng)下載 cmake portable 版本。

集成安裝:

命令

說(shuō)明

vcpkg integrate install

為所有用戶集成安裝依賴包

vcpkg integrate remove

為所有用戶移除集成安裝

vcpkg integrate project

為獨(dú)立 VS 項(xiàng)目創(chuàng)建 nuget 包引用

vcpkg integrate powershell

為 PowerShell Tab 自動(dòng)完成集成

----------------------------

---------------------------------

依賴包的管理:

vcpkg.exe remove assimp

vcpkg.exe remove --outdated

vcpkg.exe list

vcpkg.exe export assimp --7zip

導(dǎo)出時(shí)必須指定導(dǎo)出的包格式。vcpkg支持5種導(dǎo)出包格式,有:

參數(shù)

格式

–raw

以不打包的目錄格式導(dǎo)出

–nuget

以 nuget 包形式導(dǎo)出

–ifw

基于 IFW 的安裝包

–zip

以 zip 壓縮包形式導(dǎo)出

–7zip

以 7z 壓縮包形式導(dǎo)出

總結(jié)

以上是生活随笔為你收集整理的vcpkg下载mysql库_VCpkg 开源库管理工具的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。