我有一个在 Visual Studio 2017 中创建的 .dll c++ 项目。我在其中有使用 aws sdk 从 s3 存储桶获取文件的代码。
我在调试模式模式下构建了这个 dll 项目,并在我的主应用程序(c++)上使用它。它奏效了。
现在我确实做了一个 dll 项目和我的主应用程序的发布版本。我的应用程序在执行“aws sdk c++”代码时崩溃。
这是关于 aws sdk c++ 的代码片段:
int Download()
{
Aws::SDKOptions options;
Aws::InitAPI(options);
{
const Aws::String bucket_name = "timestamp-storage";
//Aws::String key_name = "";
const Aws::String region = "ap-northeast-1";
std::map<int, std::string> uploadedBioMap = BiometricDB::List();
std::map<int, std::string>::iterator i;
for (i = uploadedBioMap.begin(); i != uploadedBioMap.end(); i++) {
Aws::String key_name = i->second;
std::cout << "Downloading " << key_name << " from S3 bucket: " <<
bucket_name << std::endl;
Aws::Client::ClientConfiguration clientConfig;
if (!region.empty())
clientConfig.region = region;
Aws::S3::S3Client s3_client(clientConfig);
Aws::S3::Model::GetObjectRequest object_request;
object_request.WithBucket(bucket_name).WithKey(key_name);
auto get_object_outcome = s3_client.GetObject(object_request);
if (get_object_outcome.IsSuccess())
{
Aws::OFStream local_file;
local_file.open(("enroll/" + key_name).c_str(), std::ios::out | std::ios::binary);
local_file << get_object_outcome.GetResult().GetBody().rdbuf();
std::cout << "Done!" << std::endl;
}
else
{
std::cout << "GetObject error: " <<
get_object_outcome.GetError().GetExceptionName() << " " <<
get_object_outcome.GetError().GetMessage() << std::endl;
}
}
}
Aws::ShutdownAPI(options);
return 1;
}
希望可以有人帮帮我。