Azure Storage CPP & VCPKG

Azure Storage CPP & VCPKG

本文关键字:VCPKG CPP Storage Azure      更新时间:2023-10-16

有一个小型C++应用来测试Visual Studio 2019中的某些Azure Blob存储功能。 已按照此处的说明使用 vcpkg 安装 azure-storage-cpp sdk,但是当我尝试运行该应用程序时,出现以下链接器错误:

AzureConsoleApp.obj : 错误LNK2019: 未解析的外部符号 "__declspec(dllimport(私有:无效__cdecl azure::storage::cloud_storage_account::initialize_default_endpoints(bool(" (__imp_?initialize_default_endpoints@cloud_storage_account@storage@azure@@AEAAX_N@Z( 在函数"公共:__cdecl azure::storage::cloud_storage_account::cloud_storage_account(class azure::storage::storage_credentials const &,bool(" (??0cloud_storage_account@storage@azure@@QEAA@AEBVstorage_credentials@12@_N@Z(

vcpkg 报告已安装以下内容:

azure-storage-cpp:x64-windows-static 7.0.0
Microsoft Azure Storage Client SDK for C++ A cli...

我需要为应用程序使用 azure-storage-cpp 的静态版本,因此使用 x64-windows-static。

通过阅读 vcpkg 文档,它是一种安装并忘记类型的工具,工具本身指出:

所有 MSBuild C++ 项目现在都可以 #include 任何已安装的库。 链接将自动处理。安装新库将 使它们立即可用。

我错过了什么?

在包含 Azure Storage SDK标头之前需要定义 #define _NO_WASTORAGE_API,并在链接器输入中手动包含所有必需的 Azure Storage SDK 参考库(xmllite.lib、bcrypt.lib、rpcrt4.lib、Crypt32.lib、Winhttp.lib(。

在这里找到我的答案。