Skip to content
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

linker error when building with static libs and using s3-crt #2842

Closed
thierryba opened this issue Feb 5, 2024 · 9 comments
Closed

linker error when building with static libs and using s3-crt #2842

thierryba opened this issue Feb 5, 2024 · 9 comments
Assignees
Labels
pending-release This issue will be fixed by an approved PR that hasn't been released yet.

Comments

@thierryba
Copy link
Contributor

thierryba commented Feb 5, 2024

Describe the bug

I have built, the sdk with the options '-DBUILD_ONLY=s3;s3-crt;s3-encryption;cloudfront;cloudfront-keyvaluestore',
'-DENABLE_UNITY_BUILD=ON', '-DAUTORUN_UNIT_TESTS=OFF', '-DBUILD_SHARED_LIBS=OFF',
'-DENABLE_ZLIB_REQUEST_COMPRESSION=ON', '-DUSE_OPENSSL=ON'

In my example, I am using cmake this way: find_package(AWSSDK REQUIRED COMPONENTS s3 s3-crt)

It worked fine with only s3... but if I add s3-crt, then I'mgetting linker errors about duplicate symbols

Expected Behavior

it should link without any errors.

Current Behavior

The linker errors are:

duplicate symbol '_S3_EXPRESS_SERVICE_NAME' in:
    /usr/local/.fwsharedsrc/aws-sdk-cpp-1.11.257_1__curl-8.6.0_openssl-3.2.0_zlib-1.3-macosx-11.0-universal2/lib/libaws-cpp-sdk-s3.a[arm64][2](ub_S3.cpp.o)
    /usr/local/.fwsharedsrc/aws-sdk-cpp-1.11.257_1__curl-8.6.0_openssl-3.2.0_zlib-1.3-macosx-11.0-universal2/lib/libaws-cpp-sdk-s3-crt.a[arm64][2](ub_S3-CRT.cpp.o)
duplicate symbol '_CLASS_TAG' in:
    /usr/local/.fwsharedsrc/aws-sdk-cpp-1.11.257_1__curl-8.6.0_openssl-3.2.0_zlib-1.3-macosx-11.0-universal2/lib/libaws-cpp-sdk-s3.a[arm64][2](ub_S3.cpp.o)
    /usr/local/.fwsharedsrc/aws-sdk-cpp-1.11.257_1__curl-8.6.0_openssl-3.2.0_zlib-1.3-macosx-11.0-universal2/lib/libaws-cpp-sdk-s3-crt.a[arm64][2](ub_S3-CRT.cpp.o)
duplicate symbol '_S3_EXPRESS_QUERY_PARAM' in:
    /usr/local/.fwsharedsrc/aws-sdk-cpp-1.11.257_1__curl-8.6.0_openssl-3.2.0_zlib-1.3-macosx-11.0-universal2/lib/libaws-cpp-sdk-s3.a[arm64][2](ub_S3.cpp.o)
    /usr/local/.fwsharedsrc/aws-sdk-cpp-1.11.257_1__curl-8.6.0_openssl-3.2.0_zlib-1.3-macosx-11.0-universal2/lib/libaws-cpp-sdk-s3-crt.a[arm64][2](ub_S3-CRT.cpp.o)
duplicate symbol '_S3_EXPRESS_HEADER' in:
    /usr/local/.fwsharedsrc/aws-sdk-cpp-1.11.257_1__curl-8.6.0_openssl-3.2.0_zlib-1.3-macosx-11.0-universal2/lib/libaws-cpp-sdk-s3.a[arm64][2](ub_S3.cpp.o)
    /usr/local/.fwsharedsrc/aws-sdk-cpp-1.11.257_1__curl-8.6.0_openssl-3.2.0_zlib-1.3-macosx-11.0-universal2/lib/libaws-cpp-sdk-s3-crt.a[arm64][2](ub_S3-CRT.cpp.o)
duplicate symbol '_S3_EXPRESS_SIGNER_NAME' in:
    /usr/local/.fwsharedsrc/aws-sdk-cpp-1.11.257_1__curl-8.6.0_openssl-3.2.0_zlib-1.3-macosx-11.0-universal2/lib/libaws-cpp-sdk-s3.a[arm64][2](ub_S3.cpp.o)
    /usr/local/.fwsharedsrc/aws-sdk-cpp-1.11.257_1__curl-8.6.0_openssl-3.2.0_zlib-1.3-macosx-11.0-universal2/lib/libaws-cpp-sdk-s3-crt.a[arm64][2](ub_S3-CRT.cpp.o)

Reproduction Steps

see description.

Possible Solution

No response

Additional Information/Context

I have tried shared libs and that works... I would rather that static libs are either not a thing or that it works.

AWS CPP SDK version used

1.11.257

Compiler and Version used

Apple clang version 15.0.0 (clang-1500.1.0.2.5)

Operating System and version

macOS 14.3

@thierryba thierryba added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 5, 2024
@jmklix
Copy link
Member

jmklix commented Feb 6, 2024

What are the exact build commands that you are building this sdk with? I used the following and I'm not seeing the same error that you're getting

cmake .. -DCMAKE_INSTALL_PREFIX="<path>" -DBUILD_ONLY='s3;s3-crt;s3-encryption;cloudfront;cloudfront-keyvaluestore' -DENABLE_UNITY_BUILD=ON -DAUTORUN_UNIT_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DENABLE_ZLIB_REQUEST_COMPRESSION=ON -DUSE_OPENSSL=ON
cmake --build . --config=Debug
cmake --install . --config=Debug

I would also recommend trying to add -DFORCE_SHARED_CRT=OFF and see if that fixes your linker problems

@jmklix jmklix self-assigned this Feb 6, 2024
@jmklix jmklix added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. p2 This is a standard priority issue build-problem problems with building this sdk and removed needs-triage This issue or PR still needs to be triaged. labels Feb 6, 2024
@thierryba
Copy link
Contributor Author

thierryba commented Feb 6, 2024

Here is a complete set of instructions how to reproduce the issue on macOS with Xcode 15.2

unzip aws-sdk-cpp-1.11.257.zip
cd aws-sdk-cpp-1.11.257
./prefetch_crt_dependency.sh
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=../../awssdk -DBUILD_ONLY='s3;s3-crt' -DENABLE_UNITY_BUILD=ON -DAUTORUN_UNIT_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DENABLE_ZLIB_REQUEST_COMPRESSION=OFF -DCMAKE_BUILD_TYPE=Release
cmake --build .
cmake --install .
cd ../..
(put CmakeLists.txt and test.cpp in attachment
test.zip
)
cmake -DCMAKE_PREFIX_PATH=./awssdk -DCMAKE_CXX_STANDARD=17 .
cmake --build .

@thierryba
Copy link
Contributor Author

The problem, if I grep s3 and s3-crt, for S3_EXPRESS_SIGNER_NAME is that it find:
./generated/src/aws-cpp-sdk-s3-crt/source/S3ExpressSigner.cpp:const char *S3_EXPRESS_SIGNER_NAME = "S3ExpressSigner";
./generated/src/aws-cpp-sdk-s3/source/S3ExpressSigner.cpp:const char *S3_EXPRESS_SIGNER_NAME = "S3ExpressSigner";

if those guys were static, that would work. Should I prepare a patch?

@thierryba
Copy link
Contributor Author

create a PR here #2845

@sbiscigl sbiscigl mentioned this issue Feb 6, 2024
11 tasks
@sbiscigl
Copy link
Contributor

sbiscigl commented Feb 6, 2024

Hey @thierryba your patch looks good, just you missed the code generation bit of it. All of clients under generated are actually created through a code generation process. I created a PR with those bits added in pull/2847 which I am currently running CI on right now.

We can merge that as soon as CI finishes running if thats alright with you. Thanks for contributing!

@sbiscigl
Copy link
Contributor

sbiscigl commented Feb 6, 2024

merged my PR with the your patch applied (you are on the commit as cou-author), just includes my code gen bits, will be released and tagged today. closing your old PR. give a shout if you have any questions.

@sbiscigl sbiscigl added pending-release This issue will be fixed by an approved PR that hasn't been released yet. and removed bug This issue is a bug. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. p2 This is a standard priority issue build-problem problems with building this sdk labels Feb 6, 2024
@sbiscigl
Copy link
Contributor

sbiscigl commented Feb 6, 2024

should be released now, give a shout if you have any questions

@sbiscigl sbiscigl closed this as completed Feb 6, 2024
Copy link

github-actions bot commented Feb 6, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

@thierryba
Copy link
Contributor Author

@sbiscigl Thank you for the help here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-release This issue will be fixed by an approved PR that hasn't been released yet.
Projects
None yet
Development

No branches or pull requests

3 participants