Skip to content

Linking error on Windows (both with VS 2013 and 2015) #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
epot opened this issue Apr 7, 2016 · 16 comments
Closed

Linking error on Windows (both with VS 2013 and 2015) #151

epot opened this issue Apr 7, 2016 · 16 comments

Comments

@epot
Copy link

epot commented Apr 7, 2016

Hello,

I built the awscppsdk with Cmake and Visual Studio (tried with both 2013 and 2015 versions) sucessfully. I am trying to build an executable using it. If I only use methods to upload to S3, it works fine (meaning the putObjectRequest). But as soon as I add this line:

Aws::S3::Model::GetObjectRequest getObjectRequest;

I get a linking error:

bla.obj : error LNK2001: unresolved external symbol "char const * const Aws::Http::CONTENT_TYPE_HEADER" (?CONTENT_TYPE_HEADER@Http@Aws@@3PEBDEB)

My executable is linking against aws-cpp-sdk-s3.lib and aws-cpp-sdk-core.lib.

Any idea ?

Cheers,
Emmanuel

@dkislov
Copy link

dkislov commented Apr 8, 2016

I experienced the same link error in Visual Studio 2013. Still trying to find solution... Could someone input to that issue?

@epot
Copy link
Author

epot commented Apr 8, 2016

FYI I am now compiling in static mode and things work fine. I had other issues (crash when the destructor of ListObjectsResult was called) that were fixed at the same time.

@epot epot closed this as completed Apr 8, 2016
@epot epot reopened this Apr 8, 2016
@JonathanHenson
Copy link
Contributor

@epot what changed that it started working?

@epot
Copy link
Author

epot commented Apr 12, 2016

Sorry for the close and re-open, that was a misclick :-). I am compiling in static mode now and do not have this issue anymore. But it would be good to have the possibility to use the library in dynamic mode on windows !

@JonathanHenson
Copy link
Contributor

We don't have this issue on VS 2013 or VS 2015 for our builds, could you show me how you are building and also which version of the SDK you were using?

@epot
Copy link
Author

epot commented Apr 13, 2016

I was told to use the head a while ago because of another issue (#134). I am still using the head of that time, which was starting by b216290. I will try with the latest now to check if my issue has been fixed.

@epot epot closed this as completed Apr 13, 2016
@epot epot reopened this Apr 13, 2016
@epot
Copy link
Author

epot commented Apr 13, 2016

Argl I misclicked again...

@epot
Copy link
Author

epot commented Apr 13, 2016

I still have the same issue with the latest revision of the repository, sorry :-(. I am building with absolutely no parameters with cmake (just -G "Visual Studio 12 2013 Win64"). And then I have a C++ program trying to link against aws-cpp-sdk-s3.lib and aws-cpp-sdk-core.lib.
I just noticed that it actually works in Release mode, but not in RelWithDebInfo (coming from a default cmake).

@dkislov
Copy link

dkislov commented Apr 13, 2016

Hello , I solved issue in this way:

Building:

mkdir build
cd build
cmake .. -G "Visual Studio 12 Win64" -DBUILD_ONLY="aws-cpp-sdk-transfer" -DCUSTOM_MEMORY_MANAGEMENT=0 -DSTATIC_LINKING=0

Using:

I link aws-cpp-sdk-transfer.dll, aws-cpp-sdk-s3.dll, aws-cpp-sdk-core.dll to my custom DLL project in my VS solutionand setup these preprocessor variables in my DLL project:
AWS_SDK_PLATFORM_WINDOWS
ENABLE_WINDOWS_CLIENT
ENABLE_BCRYPT_ENCRYPTION
USE_IMPORT_EXPORT
AWS_S3_EXPORTS

That's all, issue solved

@JonathanHenson
Copy link
Contributor

If you use CMake to configure your application then you can use our targets file and it will make this much less painful. Glad you got it solved.

@ehosseini
Copy link

I have the same exact problem... recompiled the project using the instructions that dkislov posted, and that didn't solve the problem.

I noticed a weird behavior while trying to instantiate Aws::Route53Domains::Model::GetDomainDetailRequest object using the new operator... the weird behavior is that now the code compiles and runs without any complaint.

I was wondering if anyone knows why? I have copied the two lines of code below.

The following line of code doesn't run and gives the same error message posted above:
Aws::Route53Domains::Model::GetDomainDetailRequest dmreq2;

1>------ Build started: Project: CAPP1, Configuration: Release x64 ------
1> CAPP1.cpp
1>CAPP1.obj : error LNK2001: unresolved external symbol "char const * const Aws::Http::CONTENT_TYPE_HEADER" (?CONTENT_TYPE_HEADER@Http@Aws@@3PEBDEB)
1>C:\Projects\CAPP1\x64\Release\CAPP1.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

This one works though:
auto dmreq= Aws::MakeShared<Aws::Route53Domains::Model::GetDomainDetailRequest>(ALLOCATION_TAG); dmreq->SetDomainName("abc.com");

@chebz
Copy link

chebz commented May 18, 2016

If anyone still running into this problem, make sure preprocessor variables are defined as @dkislov mentioned. Have a look at dynamoDbIntegrationTests project for reference:
WIN32
_WINDOWS
_DEBUG
USE_IMPORT_EXPORT
ENABLE_WINDOWS_CLIENT
ENABLE_BCRYPT_ENCRYPTION
JSON_USE_EXCEPTION=0
GTEST_LINKED_AS_SHARED_LIBRARY=1
CMAKE_INTDIR="Debug"

krzysztof-trzepla added a commit to krzysztof-trzepla/aws-sdk-cpp that referenced this issue May 21, 2016
1f79408 Fix path to docker script in ct_run.
7d25b62 Merge commit 'ca2c63cb741a566f3ac6002a02c7dc68261b1e3b' into feature/merge-storage-helpers-functionality
ca2c63c Squashed 'bamboos/' changes from 5b55a72..69ff95b
c632173 Merge commit '327b2bc8582e88c300e225b7a66e24e61c838c9d' into feature/merge-storage-helpers-functionality
327b2bc Squashed 'clproto/' changes from 9f6d8c3..029c696
187dc43 Squashed 'bamboos/' changes from 7f7692e..5b55a72
e849607 Merge commit '187dc437339facf96cb41a22f96a71931694da5f' into feature/merge-storage-helpers-functionality
c28e567 Merge branch 'feature/VFS-1527-set-open-flags-in-open' of ssh://git.plgrid.pl:7999/vfs/helpers into feature/merge-storage-helpers-functionality
d441011 Merge branch 'feature/VFS-1484-better-client-configuration-on-mounting' of ssh://git.plgrid.pl:7999/vfs/helpers into feature/merge-storage-helpers-functionality
02eb1da Merge branch 'feature/VFS-1472-create-s3-storage-helper' of ssh://git.plgrid.pl:7999/vfs/helpers into feature/merge-storage-helpers-functionality
a6647c8 Merge pull request aws#155 in VFS/helpers from feature/VFS-1563-add-gdb-flag-to-client-s-ct_run.py to develop
cb14be5 VFS-1563 Add --gdb flag to ct_run.py .
ed62659 VFS-1472 Add documentation.
3718869 VFS-1527 Add flags to mknod and open operations.
891b85c Merge pull request aws#151 in VFS/helpers from feature/VFS-1428-support-for-multi-storage-types to develop
REVERT: 5822b42 VFS-1527 Add flags to mknod and open operations.

git-subtree-dir: helpers
git-subtree-split: 1f794085d2ac429d50358c6a18ba298ae8a81f6f
@benjypark
Copy link

For those who are having the same problem on debug mode, I got it solved with dkislov's solution.
I am using Qt with VS2013, below is how my .pro file looks like.

CONFIG(release, debug|release) {
#RELEASE
} else {
#DEBUG
DEFINES += AWS_SDK_PLATFORM_WINDOWS
ENABLE_WINDOWS_CLIENT
ENABLE_BCRYPT_ENCRYPTION
USE_IMPORT_EXPORT
AWS_S3_EXPORTS
}

INCLUDEPATH += "E:\AWS\aws-sdk-cpp-master\aws-cpp-sdk-core\include"
"E:\AWS\aws-sdk-cpp-master\aws-cpp-sdk-s3\include"

win32: LIBS += -L$$PWD/../../aws-sdk-cpp-build/aws-cpp-sdk-core/Debug/ -laws-cpp-sdk-core
-L$$PWD/../../aws-sdk-cpp-build/aws-cpp-sdk-s3/Debug/ -laws-cpp-sdk-s3
-L$$PWD/../../aws-sdk-cpp-build/aws-cpp-sdk-transfer/Debug/ -laws-cpp-sdk-transfer

Thanks,

Ben

@zhaoming029
Copy link

Even using @dkislov 's solution it promotes other build errors like:
error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_istream<char,struct std::char_traits > & __cdecl std::basic_istream<char,struct std::char_traits >::putback(char)" (_imp?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_istream<char,struct std::char_traits > & __cdecl std::basic_istream<char,struct std::char_traits >::unget(void)" (_imp?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ)

@dkislov
Copy link

dkislov commented Oct 24, 2018

Even using @dkislov 's solution it promotes other build errors like:
error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_istream<char,struct std::char_traits > & __cdecl std::basic_istream<char,struct std::char_traits >::putback(char)" (_imp?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class std::basic_istream<char,struct std::char_traits > & __cdecl std::basic_istream<char,struct std::char_traits >::unget(void)" (_imp?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ)

For VS 2017 it is much more easier to get appropriate AWS SDK Nuget package. It takes latest stable version of libraries and setup in right way all VS targets files

@paololazzari
Copy link

paololazzari commented Jun 3, 2019

I am using VS 2017 and I am trying to use the latest version of the SDK. I run into the same error:

Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "void __cdecl Aws::InitAPI(struct Aws::SDKOptions const &)" (?InitAPI@Aws@@YAXABUSDKOptions@1@@z) referenced in function _main ProjectFinal C:\Users\paolol\source\repos\ProjectFinal\ProjectFinal\Source.obj 1

@dkislov The Nuget package is not up to date

cobookman pushed a commit to cobookman/aws-sdk-cpp that referenced this issue Jan 17, 2022
* X509 Binding 
* Submodules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants