简体   繁体   English

C++ Builder 10.3 Rio 亚马逊存储服务示例

[英]C++ Builder 10.3 Rio Amazon Storage Service Example

I am trying to move an application that uses C++Builder's TAmazonConnectionInfo to access objects on Amazon Simple Storage Service (S3).我正在尝试移动使用 C++Builder 的TAmazonConnectionInfo访问 Amazon Simple Storage Service (S3) 上的对象的应用程序。 I had a version working in C++Builder 10.1 Berlin, but when I try to move it to 10.3 Rio, the link fails with an Unresolved external error:我有一个在 C++Builder 10.1 Berlin 中工作的版本,但是当我尝试将它移动到 10.3 Rio 时,链接失败并出现未解决的外部错误:

[ilink32 Error] Error: Unresolved external '__fastcall Data::Cloud::Amazonapi::TAmazonStorageService::GetObjectW(System::UnicodeString, System::UnicodeString, System::Classes::TStream *, Data::Cloud::Cloudapi::TCloudResponseInfo *, Data::Cloud::Amazonapi::TAmazonRegion)' [ilink32 错误] 错误:无法解析的外部 '__fastcall Data::Cloud::Amazonapi::TAmazonStorageService::GetObjectW(System::UnicodeString, System::UnicodeString, System::Classes::TStream *, Data::Cloud::Cloudapi ::TCloudResponseInfo *, Data::Cloud::Amazonapi::TAmazonRegion)'

The simplest reproduction of this error is:此错误的最简单再现是:

  1. Create a new C++ Builder VCL Application创建一个新的 C++ Builder VCL 应用程序
  2. Place a TAmazonConnectionInfo object and a button on the form and double-click the button在表单上放置一个 TAmazonConnectionInfo 对象和一个按钮,然后双击该按钮
  3. Replace the click handler with:将点击处理程序替换为:

     void __fastcall TForm1::Button1Click(TObject *Sender) { TCloudResponseInfo * ResponseInfo = NULL; TAmazonStorageService *StorageService = NULL; TStream* stream; String ObjectName; StorageService->GetObject(ObjectName, ObjectName, stream, ResponseInfo); }

(I realize that this routine won't work because nothing is initialized, but this will produce the link error with the least amount of code). (我意识到这个例程将不起作用,因为没有初始化任何东西,但这将以最少的代码产生链接错误)。

I looked for a code sample showing how this should work, but I cannot locate the code samples for RAD Studio 10.3 Rio on my system, and it does not appear that the samples have been updated for Rio on the RAD Studio Demo Code on SourceForge.我查找了一个代码示例,展示了这应该如何工作,但我在我的系统上找不到 RAD Studio 10.3 Rio 的代码示例,而且 SourceForge 上的RAD Studio 演示代码似乎没有更新 Rio 的示例。

I did find the samples on Github at https://github.com/Embarcadero/RADStudio10.3Demos/tree/master/CPP , but the Cloud samples do not appear to have been migrated for C++ Builder, only for Object Pascal.我确实在https://github.com/Embarcadero/RADStudio10.3Demos/tree/master/CPP上找到了 Github 上的示例,但 Cloud 示例似乎并未针对 C++ Builder 迁移,仅针对 Object Pascal。

I tried adding CloudService.lib to the project, but that did not help.我尝试将CloudService.lib添加到项目中,但这没有帮助。 Neither did adding:也没有添加:

#pragma link "Data.Cloud.CloudAPI"
#pragma link "Data.Cloud.AmazonAPI"

So, is there a working C++Builder sample that compiles and links under 10.3 Rio?那么,是否有一个可以在 10.3 Rio 下编译和链接的工作 C++Builder 示例? How can I get this project to compile and link?我怎样才能让这个项目编译和链接?

The problem is that the Data.Cloud.AmazonAPI.hpp header includes internally the wingdi.h Windows API header.问题在于Data.Cloud.AmazonAPI.hpp标头在内部包含wingdi.h Windows API 标头。 This header has a macro that replaces GetObject for GetObjectA/W .此标头具有一个宏,用于将GetObject替换为GetObjectA/W

The workaround I managed to get working was to add the following to the Data.Cloud.AmazonAPI.hpp header, just below where the #includes end (around line 27):我设法开始工作的解决方法是将以下内容添加到 Data.Cloud.AmazonAPI.hpp 标头中,就在 #includes 结尾的下方(第 27 行左右):

#pragma push_macro("GetObject")
#undef GetObject

Then, at the end of the header, just before the #pragma delphiheader end.然后,在标题的末尾,就在#pragma delphiheader end.之前#pragma delphiheader end. (around line 897) add the following: (在第 897 行附近)添加以下内容:

#pragma pop_macro("GetObject")

This solves the headers issue, but you still have to add this around the code where you want to use that function so it compiles, otherwise it is going to try to compile GetObjectW that now doesn't exists at compile time.这解决了标头问题,但您仍然必须在要使用该函数的代码周围添加它,以便进行编译,否则它将尝试编译现在在编译时不存在的 GetObjectW。

I had the same problem.我有同样的问题。 I just tested this solution, it works!我刚刚测试了这个解决方案,它有效! Thank you!谢谢!

You must copy the file to the desktop in order to be able to modify it, then recopy it in the installation directory.您必须将该文件复制到桌面才能对其进行修改,然后将其重新复制到安装目录中。

I add that it is necessary to initialize the property "Storage EndPoint" of the TAmazonConnectInfo component with the name of the EndPoint that you must create from your Bucket我补充说,有必要使用您必须从 Bucket 创建的 EndPoint 的名称来初始化 TAmazonConnectInfo 组件的属性“Storage EndPoint”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 亚马逊相当于谷歌存储传输服务 - Amazon equivalent of Google Storage Transfer Service Amazon Web Service,缺少存储卷 - Amazon Web Service, Missing Storage Volume 亚马逊的AWS Elasticache-C#示例 - Amazon's AWS elasticache - c# example Amazon SQS 是否有任何服务级别协议 (SLA)? 例如,它的正常运行时间 - Is there any Service Level Agreement (SLA) for Amazon SQS? For example, its uptime 面向经过身份验证的用户的 Amazon Web Service (AWS) 私有存储 - Amazon Web Service (AWS) Private Storage For Authenticated Users 在 Mac 上的 Windows 的 Amazon Web 服务模拟器上添加更多存储空间 - Add more storage on a Amazon Web Service emulator for Windows on Mac Amazon S3 Glacier存储与直接使用Amazon Glacier服务是否相同? - Is Amazon S3 Glacier Storage the same as using the Amazon Glacier Service Directly? 适用于C ++的AWS开发工具包是否可以与Embarcadero C ++构建器一起使用? - Does AWS SDK for C++ work with Embarcadero C++ builder? 如何阻止Amazon S3(Amazon Simple Storage Service)中的恶意程序? - How To Block Bad Bots in Amazon S3 (Amazon Simple Storage Service)? 调整Amazon RDS存储的大小 - Resize Amazon RDS storage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM