-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
"unresolved external symbol" When linking to the library #2421
Comments
I'm having exactly the same issue on Windows 10 and Visual Studio 2022. I built and installed the 'master' branch instead of the 'main' branch and that one compiles without linker errors. |
What are the build commands that you are using? |
As said above, I did the same steps for the 'master' branch (--branch master) and that one did not have the linker error so it compiled properly. |
Hi @RobertvandeVelde , It is quite strange that you encounter only following linker error.
I would expect much more similar linker errors because this is not a unique variable following this C++ static const variable pattern. Also, could you please specify cmake configuration you have for the SDK build and the SDK consuming app? What C++ version (11/14/17/20) are using?
This part is not very clear, could you please elaborate a bit? Are you saying that this dir contains SDK and CRT headers or you are talking about property "additional include dirs" setting in a VS vcxproj config? Best regards, |
Thanks for your reply! I will remove the current installation and then redownload, build and install the main branch, although it might take some hours. I'm using C++14 (default option). For cmake, I open cmake gui (version 3.26.2), set the source and binary directories and then press configure and generate, all with default options. After building and installing with MSBuild, I copy only the libs and headers that I currently need (for a S3 client) from the installation directory to my project directory. I took the headers from C:\Program Files (x86)\aws-cpp-sdk-all\include\aws and the libs from C:\Program Files (x86)\aws-cpp-sdk-all\bin and C:\Program Files (x86)\aws-cpp-sdk-all\lib. Update to clarify a bit more what went wrong yesterday: when configuring/generating with cmake the parameter "Treat Warnings As Errors = off" is apparently ignored. During the subsequent build I saw the following error:
I tried to use cmake via the windows cmd and placing the build directory outside the SDK source directory but that didn't help. I also installed cmake 3.21 instead of 3.26 but it turned out that that version does not support the VS 2022 C++ compiler. I opened the SDK solution to turn the "Treat Warnings As Errors" setting off (/WX-) for all 735 projects and then it finished the SDK build without any fails. However, when copying the resulting libs and headers to my project the unresolved external symbol error appeared during the project build. I will try to build the SDK once more tomorrow although I expect the error to show up again. Otherwise I will just use the master branch since that source version builds effortlessly using the instructions on the documentation page. Last update: I build the main source again but incorporating it still leads to the unresolved external symbol error in my project. I also get the same two warnings (conversion from 'size_t' to 'uInt', possible loss of data) that cause the SDK build to fail unless the setting "Treat Warnings As Errors" is set to /WX- in the project properties for all projects. I'm not experienced in building large external libraries so it could be that I'm missing something. For now I'll be using another source version. Thanks for the help anyway! |
Can you also try building the sdk statically with the follow cmake arguments: |
Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one. |
I will try it this weekend, I'm busy with other things currently. I'll let you know. |
Turning both options off leads to errors during build for both main and master source versions. If I only turn off BUILD_SHARED_LIBS I can build the SDK, but when I use it in my project I get 103 unresolved externals for the main source. If I use master then my project builds without errors. |
The issue still remains. I am also experiencing the same issue. So what I did to fix mine was to switched to another branch that didn't have the issue |
I ran into the same issue. Built from source as shared libraries, Then tried to compile "Hello S3" in my CMake project, but added the libraries manually, so not using The simple fix is to define USE_IMPORT_EXPORT before including any SDK headers. |
@code-disaster This way saved my life. Thanks a lot! |
What does your CMakeLists.txt look like? Can you make sure that you have find_package(AWSSDK REQUIRED COMPONENTS s3 lambda transfer) |
Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one. |
The issue exists for 1.11.21. The solution is to define USE_IMPORT_EXPORT before including any SDK headers. |
Describe the bug
I'm trying to build a simple test program that downloads a file from a S3 bucket. I've already done that a couple of times with older versions of the SDK, but with the current version, It doesn't seems to work since I can't link properly with the library:
In older versions, I only had to link to three libraries: aws-cpp-sdk, aws-cpp-sdk-s3 and aws-cpp-sdk-transfer.
Now, even linking with all libraries generated by the build, it still complains about an unresolved external symbol.
Expected Behavior
To link and work properly
Current Behavior
It does not link, complaining about the following unresolved external symbol:
error LNK2001: unresolved external symbol "public: static unsigned __int64 const Aws::Endpoint::AWSPartitions::PartitionsBlobSize" (?PartitionsBlobSize@AWSPartitions@Endpoint@Aws@@2_KB)
Reproduction Steps
BUILD_ONLY
, setting it tocore;s3;transfer
std::shared_ptr<Aws::S3::S3Client>
variableaws-cpp-sdk-transfer
,aws-cpp-sdk-s3
,aws-cpp-sdk-core
,aws-c-auth
,aws-c-cal
,aws-c-common
,aws-c-compression
,aws-c-event-stream
,aws-checksums
,aws-c-http
,aws-c-io
,aws-c-mqtt
,aws-crt-cpp
,aws-c-s3
,aws-c-sdkutils
)Possible Solution
No response
Additional Information/Context
No response
AWS CPP SDK version used
1.11.48
Compiler and Version used
Visual Studio 2019 (MSVC 19.29.30147.0)
Operating System and version
Windows 11 Pro 22H2 build 22621.1413
The text was updated successfully, but these errors were encountered: