4
votes

I'm trying to link aws-sdk-ec2 to my application,but I'm a getting a linker error from Visual Studio 2013.I have compiled the SDK successfully and linked aws-sdk-core.lib and aws-sdk-ec2.lib on my project settings.

The error I'm getting is:

Error 1 error LNK2001: unresolved external symbol "char const * const Aws::Http::CONTENT_TYPE_HEADER" (?CONTENT_TYPE_HEADER@Http@Aws@@3PBDB) E:\Users\..\..\..\main.obj

Any ideas what is the problem ? Do I need to link any aws-sdk-* component ?

3

3 Answers

1
votes

I have solved the issue by added

USE_IMPORT_EXPORT

to my preprocessor definitions, project->properties->c/c++ ->preprocessor

0
votes

Yes, the output from the visual-c++ linker is really cryptic on this one. The dll import stuff hasn't been declared when you compiled your code. What the error is really saying is that the linker can't find ANY of the symbols. Try adding USE_IMPORT_EXPORT to your compiler flags.

Also are you using the NuGet package or compiling from source?

0
votes

I get the error gone when dynamically linked the library:

  • defined USE_IMPORT_EXPORT

I used the following in my code:

#define USE_IMPORT_EXPORT

but you surely can define it with compiler settings Project Configuration Properties(*) -> C/C++ -> Preprocessor -> -> Preprocessor Definitions

Now I see a piece of official help in regards to the definition in the official code storage: https://github.com/aws/aws-sdk-cpp/blob/main/Docs/SDK_usage_guide.md#build-defines

  • Change linkage to dynamic:

For debug version: Project Configuration Properties(*) -> C/C++ -> Code Generation -> Runtime Library set to Multi-threaded Debug DLL (/MDd) instead of linking statically

In release version, be sure to set Multi-threaded DLL (/MD) and to link to the release version of the library binaries.

* - Right click on the project in Solution Explorer and Properties