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

Linking against SDK fails when CRT is built as shared object #2643

Open
smthsm opened this issue Aug 29, 2023 · 1 comment
Open

Linking against SDK fails when CRT is built as shared object #2643

smthsm opened this issue Aug 29, 2023 · 1 comment
Assignees
Labels
bug This issue is a bug. Cmake Cmake related submissions p2 This is a standard priority issue

Comments

@smthsm
Copy link

smthsm commented Aug 29, 2023

Describe the bug

When the CRT library is built as a shared object, applications fail to link against the SDK using pkgconfig because the aws-cpp-sdk-core.pc file doesn't include a dependency on the CRT shared libs (I think it should either be in the Libs: or Requires: entries).

This doesn't happen by default when the CRT is built as submodules within the main build (i.e. with BUILD_DEPS=ON) because in that case, CRT is linked statically into the aws-cpp-sdk-core.so file.

Expected Behavior

Applications and libraries can build against the SDK when CRT is linked dynamically.

Current Behavior

The link stage of building a gstreamer library that uses the SDK fails due to the error undefined reference to 'Aws::Crt::ApiAllocator()'. Full build logs:

root@localhost:/src/amazon-s3-gst-plugin# ninja -C build
ninja: Entering directory `build'
[5/12] Compiling C++ object src/libgstawscredentials-1.0.so.p/gstawscredentials.cpp.o
../src/gstawscredentials.cpp: In function ‘void _do_init(GType)’:
../src/gstawscredentials.cpp:223:3: warning: missing initializer for member ‘_GstValueTable::_gst_reserved’ [-Wmissing-field-initializers]
  223 |   };
      |   ^
[6/12] Linking target src/libgstawscredentials-1.0.so
FAILED: src/libgstawscredentials-1.0.so
c++  -o src/libgstawscredentials-1.0.so src/libgstawscredentials-1.0.so.p/gstawscredentials.cpp.o -Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,libgstawscredentials-1.0.so -Wl,-rpath,/usr/local/lib -Wl,-rpath-link,/usr/local/lib /usr/local/lib/libaws-cpp-sdk-sts.so /usr/local/lib/libaws-cpp-sdk-core.so /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so /usr/lib/x86_64-linux-gnu/libgobject-2.0.so /usr/lib/x86_64-linux-gnu/libglib-2.0.so -Wl,--end-group
/usr/bin/ld: src/libgstawscredentials-1.0.so.p/gstawscredentials.cpp.o: in function `Aws::Endpoint::DefaultEndpointProvider<Aws::Client::GenericClientConfiguration<false>, Aws::Endpoint::BuiltInParameters, Aws::Endpoint::ClientContextParameters>::DefaultEndpointProvider(char const*, unsigned long)':
/usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:53: undefined reference to `Aws::Crt::ApiAllocator()'
/usr/bin/ld: /usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:54: undefined reference to `Aws::Crt::ByteCursorFromArray(unsigned char const*, unsigned long)'
/usr/bin/ld: /usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:53: undefined reference to `Aws::Crt::ByteCursorFromArray(unsigned char const*, unsigned long)'
/usr/bin/ld: /usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:53: undefined reference to `Aws::Crt::Endpoints::RuleEngine::RuleEngine(aws_byte_cursor const&, aws_byte_cursor const&, aws_allocator*)'
/usr/bin/ld: src/libgstawscredentials-1.0.so.p/gstawscredentials.cpp.o: in function `Aws::Endpoint::DefaultEndpointProvider<Aws::Client::GenericClientConfiguration<false>, Aws::Endpoint::BuiltInParameters, Aws::Endpoint::ClientContextParameters>::~DefaultEndpointProvider()':
/usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:63: undefined reference to `Aws::Crt::Endpoints::RuleEngine::~RuleEngine()'
/usr/bin/ld: /usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:63: undefined reference to `Aws::Crt::Endpoints::RuleEngine::~RuleEngine()'
/usr/bin/ld: /usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:63: undefined reference to `Aws::Crt::Endpoints::RuleEngine::~RuleEngine()'
collect2: error: ld returned 1 exit status
[7/12] Compiling C++ object src/libmultipartuploader.a.p/gsts3multipartuploader.cpp.o
ninja: build stopped: subcommand failed.

Reproduction Steps

The build failure can be reproduced using the below Dockerfile.

Create a file named Dockerfile containing:

FROM public.ecr.aws/lts/ubuntu:22.04

RUN apt-get update && apt-get -y -qq install \
        git curl cmake libcurl4-openssl-dev openssl libssl-dev \
        gstreamer1.0-plugins-base libgstreamer1.0-dev \
        python3-pip python3-setuptools \
    && pip3 install \
        meson ninja

RUN mkdir /crt
WORKDIR /crt
RUN git clone --depth 1 --recurse-submodules https://github.com/awslabs/aws-crt-cpp.git
RUN cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/usr/local/lib -DBUILD_SHARED_LIBS=ON aws-crt-cpp
RUN make -j 4  && make install

RUN mkdir /sdk
WORKDIR /sdk
RUN git clone --depth 1 https://github.com/aws/aws-sdk-cpp.git
RUN cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/usr/local/lib -DBUILD_DEPS=OFF -DENABLE_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DBUILD_ONLY="s3;sts" aws-sdk-cpp
RUN make -j 4  && make install

RUN mkdir /src
WORKDIR /src
RUN git clone https://github.com/amzn/amazon-s3-gst-plugin.git

WORKDIR /src/amazon-s3-gst-plugin
RUN meson build

ENTRYPOINT /bin/bash

Then run these commands to reproduce the build:

$ docker build -t aws-sdk-cpp-build-issue:latest .
$ docker run -it aws-sdk-cpp-build-issue:latest
(inside container) ninja -C build

Possible Solution

No response

Additional Information/Context

No response

AWS CPP SDK version used

v1.10.30 (but also happens with latest)

Compiler and Version used

gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

Operating System and version

Ubuntu 22.04

@smthsm smthsm added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 29, 2023
@yasminetalby yasminetalby self-assigned this Aug 29, 2023
@yasminetalby yasminetalby added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Aug 30, 2023
@yasminetalby yasminetalby added p2 This is a standard priority issue and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Oct 3, 2023
@yasminetalby
Copy link
Contributor

Hello @smthsm ,

Thank you very much for your submission.
We have been working on some updates to the build/configurations of this sdk. This would issue falls under the removing the need to pull dependencies via git submodules tasks. You can track the progress here: #1888

Best regards,

Yasmine

@jmklix jmklix added the Cmake Cmake related submissions label Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. Cmake Cmake related submissions p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

3 participants