所以我试图使用aws sdk cpp将本地文件上传到aws s3。 这是我从问题here
中获取的示例代码#include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>
#include <aws/core/utils/HashingUtils.h>
#include <aws/s3/model/PutObjectRequest.h>
#include <iostream>
#include <fstream>
using namespace Aws::S3::Model;
using namespace std;
using namespace Aws::Utils;
static const char* KEY = "try.txt";
static const char* BUCKET = "bucket-name";
int main()
{
Aws::SDKOptions options;
Aws::InitAPI(options);
Aws::Client::ClientConfiguration myConf;
myConf.region = Aws::Region::US_EAST_2;
Aws::S3::S3Client s3_client(myConf);
const Aws::String bucket_name = BUCKET;
const Aws::String key_name = KEY;
const Aws::String dir_name = "C:/Users/linda.naoui/source/repos/Upload s3";
std::cout << "Uploading " << key_name << " to S3 bucket: " <<
bucket_name << std::endl;
Aws::S3::Model::PutObjectRequest object_request;
object_request.WithBucket(bucket_name).WithKey(key_name);
auto input_data = Aws::MakeShared<Aws::FStream>(key_name.c_str(), dir_name.c_str(), std::ios_base::in);
object_request.SetBody(input_data);
auto put_object_outcome = s3_client.PutObject(object_request);
if (put_object_outcome.IsSuccess()) {
std::cout << "Done!" << std::endl;
}
else {
std::cout << "PutObject error: " <<
put_object_outcome.GetError().GetExceptionName() << " " <<
put_object_outcome.GetError().GetMessage() << std::endl;
}
Aws::ShutdownAPI(options);
return 0;
}
我有很多与dll导入相关的类似错误,我使用Nuget软件包安装了aws s3 sdk和aws sdk核心,我目前在Visual Studio 2019中。
严重性代码描述项目文件行抑制状态 错误LNK2019无法解析的外部符号“ __declspec(dllimport)public:__thiscall Aws :: S3 :: Model :: PutObjectResult ::〜PutObjectResult(void)”(__imp _ ?? 1PutObjectResult @ Model @ S3 @ Aws @@ QAE @ XZ)函数“ public:__thiscall Aws :: Utils ::结果> ::〜结果>(void)”(?? 1?$ Outcome @ VPutObjectResult @ Model @ S3 @ Aws @@ V?$ AWSError @ W4S3Errors @ S3 @ Aws @ @@ Client @ 4 @@ Utils @ Aws @@ QAE @ XZ)上传s3 C:\ Users \ linda.naoui \ source \ repos \ Upload s3 \ Upload s3 \ S3.obj 1
严重性代码描述项目文件行抑制状态 错误LNK2019无法解析的外部符号“ __declspec(dllimport)void __cdecl Aws :: InitAPI(struct Aws :: SDKOptions const&)”(__imp_?InitAPI @ Aws @@ YAXABUSDKOptions @ 1 @@ Z)在函数_main中引用s3 C:\ Users \ linda.naoui \ source \ repos \ Upload s3 \ Upload s3 \ S3.obj 1
我不确定问题是否在于链接窗口为空
答案 0 :(得分:1)
我通过卸载Visual Studio 2019并改用Visual Studio 2017解决了该问题