[英]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:此错误的最简单再现是:
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.