最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

amazon web services - Unresolved externals using AWS C++ SDK (S3) - Stack Overflow

programmeradmin6浏览0评论

I'm using the AWS SDK for C++ in Visual Studio 2022 Community Edition. When I attempt to compile, I get errors about unresolved externals. As far as I can tell, I've linked to the correct libraries.

Note: I did find I had to include the AWS related headers before #include <windows.h> to get around some other conflict.

I need for a program to upload some files to S3 using code derived from a sample that Amazon provides ( found here: .cpp ).

When I attempt to compile, I'm getting errors about unresolved externals. I did link to the following libraries.


#pragma comment(lib, "aws-cpp-sdk-core.lib")
#pragma comment(lib, "aws-cpp-sdk-s3.lib")
#pragma comment(lib, "aws-cpp-sdk-transfer.lib")


Right now, I'm compiling for debug mode. I've made sure that the folders I've included in my project for linking to libraries are the ones that link to debug mode for static linking. The code of interest that contaisn the references that cannot be resolved is here.

#include "SaveFileToS3.h"

#include <aws/core/Aws.h>
#include <aws/core/utils/threading/Executor.h>
#include <aws/transfer/TransferManager.h>
#include <aws/transfer/TransferHandle.h>
#include <aws/s3/S3Client.h>
#include <aws/core/utils/memory/AWSMemory.h>
#include <aws/core/utils/memory/stl/AWSStreamFwd.h>
#include <aws/core/utils/stream/PreallocatedStreamBuf.h>
#include <aws/core/utils/StringUtils.h>

#include <locale>
#include <codecvt>

void SaveFileToS3(std::wstring fileName, std::wstring bucket, std::wstring key, std::wstring mimeType)
{

    Aws::SDKOptions options;
    Aws::InitAPI(options);

    std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
    Aws::String awsFileName = converter.to_bytes(fileName);
    Aws::String awsMimeType = converter.to_bytes(mimeType);
    Aws::String awsKey = converter.to_bytes(key);
    Aws::String awsBucket = converter.to_bytes(bucket);

    auto s3_client = Aws::MakeShared<Aws::S3::S3Client>("S3Client");
    auto executor = Aws::MakeShared<Aws::Utils::Threading::PooledThreadExecutor>("executor", 25);
    Aws::Transfer::TransferManagerConfiguration transfer_config(executor.get());
    transfer_config.s3Client = s3_client;
    auto transfer_manager = Aws::Transfer::TransferManager::Create(transfer_config);
    auto uploadHandle = transfer_manager->UploadFile(
        awsFileName,
        awsBucket,
        awsKey,
        awsMimeType,
        Aws::Map<Aws::String, Aws::String>()
    );
    uploadHandle->WaitUntilFinished();
    bool success = uploadHandle->GetStatus() == Aws::Transfer::TransferStatus::COMPLETED;
    Aws::ShutdownAPI(options);
}

The entirety of the output from attempting to build follows.

Build started at 12:10 AM...
1>------ Build started: Project: ScreenShot, Configuration: Debug x64 ------
1>   Creating library C:\Users\joeli\source\repos\ScreenShot\x64\Debug\ScreenShot.lib and object C:\Users\joeli\source\repos\ScreenShot\x64\Debug\ScreenShot.exp
1>LINK : warning LNK4217: symbol '??0PooledThreadExecutor@Threading@Utils@Aws@@QEAA@_KW4OverflowPolicy@123@@Z (public: __cdecl Aws::Utils::Threading::PooledThreadExecutor::PooledThreadExecutor(unsigned __int64,enum Aws::Utils::Threading::OverflowPolicy))' defined in 'aws-cpp-sdk-core.lib(ub_core.obj)' is imported by 'ScreenShot.obj' in function '"class Aws::Utils::Threading::PooledThreadExecutor * __cdecl std::construct_at<class Aws::Utils::Threading::PooledThreadExecutor,int>(class Aws::Utils::Threading::PooledThreadExecutor * const,int &&)" (??$construct_at@VPooledThreadExecutor@Threading@Utils@Aws@@H@std@@YAPEAVPooledThreadExecutor@Threading@Utils@Aws@@QEAV1234@$$QEAH@Z)'
1>LINK : warning LNK4217: symbol '??1PooledThreadExecutor@Threading@Utils@Aws@@UEAA@XZ (public: virtual __cdecl Aws::Utils::Threading::PooledThreadExecutor::~PooledThreadExecutor(void))' defined in 'aws-cpp-sdk-core.lib(ub_core.obj)' is imported by 'ScreenShot.obj' in function '"public: virtual void * __cdecl Aws::Utils::Threading::PooledThreadExecutor::`scalar deleting destructor'(unsigned int)" (??_GPooledThreadExecutor@Threading@Utils@Aws@@UEAAPEAXI@Z)'
1>LINK : warning LNK4217: symbol '??0ClientConfiguration@Client@Aws@@QEAA@XZ (public: __cdecl Aws::Client::ClientConfiguration::ClientConfiguration(void))' defined in 'aws-cpp-sdk-core.lib(ub_core.obj)' is imported by 'ScreenShot.obj' in function '"class Aws::S3::S3Client * __cdecl std::construct_at<class Aws::S3::S3Client>(class Aws::S3::S3Client * const)" (??$construct_at@VS3Client@S3@Aws@@$$V@std@@YAPEAVS3Client@S3@Aws@@QEAV123@@Z)'
1>LINK : warning LNK4217: symbol '??1ClientConfiguration@Client@Aws@@QEAA@XZ (public: __cdecl Aws::Client::ClientConfiguration::~ClientConfiguration(void))' defined in 'aws-cpp-sdk-core.lib(ub_core.obj)' is imported by 'ScreenShot.obj' in function '"class Aws::S3::S3Client * __cdecl std::construct_at<class Aws::S3::S3Client>(class Aws::S3::S3Client * const)" (??$construct_at@VS3Client@S3@Aws@@$$V@std@@YAPEAVS3Client@S3@Aws@@QEAV123@@Z)'
1>LINK : warning LNK4217: symbol '??0S3Client@S3@Aws@@QEAA@AEBUClientConfiguration@Client@2@W4PayloadSigningPolicy@AWSAuthV4Signer@42@_N@Z (public: __cdecl Aws::S3::S3Client::S3Client(struct Aws::Client::ClientConfiguration const &,enum Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy,bool))' defined in 'aws-cpp-sdk-s3.lib(ub_S3.obj)' is imported by 'ScreenShot.obj' in function '"class Aws::S3::S3Client * __cdecl std::construct_at<class Aws::S3::S3Client>(class Aws::S3::S3Client * const)" (??$construct_at@VS3Client@S3@Aws@@$$V@std@@YAPEAVS3Client@S3@Aws@@QEAV123@@Z)'
1>LINK : warning LNK4217: symbol '??1S3Client@S3@Aws@@UEAA@XZ (public: virtual __cdecl Aws::S3::S3Client::~S3Client(void))' defined in 'aws-cpp-sdk-s3.lib(ub_S3.obj)' is imported by 'ScreenShot.obj' in function '"public: virtual void * __cdecl Aws::S3::S3Client::`scalar deleting destructor'(unsigned int)" (??_GS3Client@S3@Aws@@UEAAPEAXI@Z)'
1>LINK : warning LNK4217: symbol '??0PutObjectRequest@Model@S3@Aws@@QEAA@XZ (public: __cdecl Aws::S3::Model::PutObjectRequest::PutObjectRequest(void))' defined in 'aws-cpp-sdk-s3.lib(ub_S3.obj)' is imported by 'ScreenShot.obj' in function '"public: __cdecl Aws::Transfer::TransferManagerConfiguration::TransferManagerConfiguration(class Aws::Utils::Threading::Executor *)" (??0TransferManagerConfiguration@Transfer@Aws@@QEAA@PEAVExecutor@Threading@Utils@2@@Z)'
1>LINK : warning LNK4217: symbol '??1PutObjectRequest@Model@S3@Aws@@UEAA@XZ (public: virtual __cdecl Aws::S3::Model::PutObjectRequest::~PutObjectRequest(void))' defined in 'aws-cpp-sdk-s3.lib(ub_S3.obj)' is imported by 'ScreenShot.obj' in function '"int `public: __cdecl Aws::Transfer::TransferManagerConfiguration::TransferManagerConfiguration(class Transfer::Utils::Threading::Executor *)'::`1'::dtor$1" (?dtor$1@?0???0TransferManagerConfiguration@Transfer@Aws@@QEAA@PEAVExecutor@Threading@Utils@2@@Z@4HA)'
1>LINK : warning LNK4217: symbol '??0CreateMultipartUploadRequest@Model@S3@Aws@@QEAA@XZ (public: __cdecl Aws::S3::Model::CreateMultipartUploadRequest::CreateMultipartUploadRequest(void))' defined in 'aws-cpp-sdk-s3.lib(ub_S3.obj)' is imported by 'ScreenShot.obj' in function '"public: __cdecl Aws::Transfer::TransferManagerConfiguration::TransferManagerConfiguration(class Aws::Utils::Threading::Executor *)" (??0TransferManagerConfiguration@Transfer@Aws@@QEAA@PEAVExecutor@Threading@Utils@2@@Z)'
1>LINK : warning LNK4217: symbol '??1CreateMultipartUploadRequest@Model@S3@Aws@@UEAA@XZ (public: virtual __cdecl Aws::S3::Model::CreateMultipartUploadRequest::~CreateMultipartUploadRequest(void))' defined in 'aws-cpp-sdk-s3.lib(ub_S3.obj)' is imported by 'ScreenShot.obj' in function '"int `public: __cdecl Aws::Transfer::TransferManagerConfiguration::TransferManagerConfiguration(class Transfer::Utils::Threading::Executor *)'::`1'::dtor$2" (?dtor$2@?0???0TransferManagerConfiguration@Transfer@Aws@@QEAA@PEAVExecutor@Threading@Utils@2@@Z@4HA)'
1>LINK : warning LNK4217: symbol '??0UploadPartRequest@Model@S3@Aws@@QEAA@XZ (public: __cdecl Aws::S3::Model::UploadPartRequest::UploadPartRequest(void))' defined in 'aws-cpp-sdk-s3.lib(ub_S3.obj)' is imported by 'ScreenShot.obj' in function '"public: __cdecl Aws::Transfer::TransferManagerConfiguration::TransferManagerConfiguration(class Aws::Utils::Threading::Executor *)" (??0TransferManagerConfiguration@Transfer@Aws@@QEAA@PEAVExecutor@Threading@Utils@2@@Z)'
1>LINK : warning LNK4217: symbol '??1UploadPartRequest@Model@S3@Aws@@UEAA@XZ (public: virtual __cdecl Aws::S3::Model::UploadPartRequest::~UploadPartRequest(void))' defined in 'aws-cpp-sdk-s3.lib(ub_S3.obj)' is imported by 'ScreenShot.obj' in function '"int `public: __cdecl Aws::Transfer::TransferManagerConfiguration::TransferManagerConfiguration(class Transfer::Utils::Threading::Executor *)'::`1'::dtor$3" (?dtor$3@?0???0TransferManagerConfiguration@Transfer@Aws@@QEAA@PEAVExecutor@Threading@Utils@2@@Z@4HA)'
1>ScreenShot.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: enum Aws::Transfer::TransferStatus __cdecl Aws::Transfer::TransferHandle::GetStatus(void)const " (__imp_?GetStatus@TransferHandle@Transfer@Aws@@QEBA?AW4TransferStatus@23@XZ) referenced in function "void __cdecl SaveFileToS3(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >)" (?SaveFileToS3@@YAXV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@000@Z)
1>ScreenShot.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl Aws::Transfer::TransferHandle::WaitUntilFinished(void)const " (__imp_?WaitUntilFinished@TransferHandle@Transfer@Aws@@QEBAXXZ) referenced in function "void __cdecl SaveFileToS3(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >)" (?SaveFileToS3@@YAXV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@000@Z)
1>ScreenShot.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class std::shared_ptr<class Aws::Transfer::TransferManager> __cdecl Aws::Transfer::TransferManager::Create(struct Aws::Transfer::TransferManagerConfiguration const &)" (__imp_?Create@TransferManager@Transfer@Aws@@SA?AV?$shared_ptr@VTransferManager@Transfer@Aws@@@std@@AEBUTransferManagerConfiguration@23@@Z) referenced in function "void __cdecl SaveFileToS3(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >)" (?SaveFileToS3@@YAXV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@000@Z)
1>ScreenShot.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::shared_ptr<class Aws::Transfer::TransferHandle> __cdecl Aws::Transfer::TransferManager::UploadFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct std::less<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > const &,class std::shared_ptr<class Aws::Client::AsyncCallerContext const > const &)" (__imp_?UploadFile@TransferManager@Transfer@Aws@@QEAA?AV?$shared_ptr@VTransferHandle@Transfer@Aws@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@000AEBV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@5@AEBV?$shared_ptr@$$CBVAsyncCallerContext@Client@Aws@@@5@@Z) referenced in function "void __cdecl SaveFileToS3(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >)" (?SaveFileToS3@@YAXV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@000@Z)
1>C:\Users\joeli\source\repos\ScreenShot\x64\Debug\ScreenShot.exe : fatal error LNK1120: 4 unresolved externals
1>Done building project "ScreenShot.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 12:10 AM and took 00.842 seconds ==========

These errors would be expected when someone failed to link to the related lib, but I've linked to the lib and have gotten these errors anyway.

发布评论

评论列表(0)

  1. 暂无评论