在Ubuntu上使用cmake安装AWS SDK C++,安装第三方库时出现问题

3phpmpom  于 2022-11-11  发布在  其他
关注(0)|答案(4)|浏览(411)

我正在Ubuntu 20.04中安装aws-cpp-sdk,安装步骤如下:https://github.com/aws/aws-sdk-cpp
我按照工作的说明从源代码构建/安装SDK。安装位置:

  • /usr/本地/库
  • /usr/本地/包含/aws

我按照说明构建/安装了aws-c-common(尽管我没有使用DCMAKE_INSTALL_PREFIX)。
我尝试编译aws-checksums,但无法通过cmake。当我在build目录(位于code目录中)中运行cmake ..时,我得到:

-- The C compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
/usr/local/lib/cmake/lib/cmake
CMake Error at CMakeLists.txt:32 (include):
  include could not find load file:

    AwsCFlags

CMake Error at CMakeLists.txt:33 (include):
  include could not find load file:

    AwsCheckHeaders

CMake Error at CMakeLists.txt:34 (include):
  include could not find load file:

    AwsSharedLibSetup

CMake Error at CMakeLists.txt:35 (include):
  include could not find load file:

    AwsSanitizers

CMake Error at CMakeLists.txt:37 (include):
  include could not find load file:

    AwsFindPackage

CMake Error at CMakeLists.txt:38 (include):
  include could not find load file:

    AwsFeatureTests

CMake Error at CMakeLists.txt:116 (aws_set_common_properties):
  Unknown CMake command "aws_set_common_properties".

-- Configuring incomplete, errors occurred!
See also ...

我试过将前缀指向sdk安装文件夹,但这并没有解决我的问题。这就是我遇到的问题。任何输入都是感激的。谢谢。

sqyvllje

sqyvllje1#

如果要从源代码构建,请确保使用以下命令

git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp

我在构建时遇到了类似的问题,因为我缺少**--recurse-submodules**标记。我在运行Ubuntu的Docker容器中构建。我的解决方案是针对AWS cpp sdk的,但它可能也适用于您的情况。

x33g5p2x

x33g5p2x2#

我在Dockerfile中执行此操作,它可以正常运行:

RUN cd /tmp \
  && git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp.git \
  && cd aws-sdk-cpp \
  && mkdir build \
  && cd build \
  && cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="ecr" \
  && make \
  && make install

它的构建也没有-DBUILD_ONLY选项。然而,这是在Ubuntu 18.04 LTS上,而不是20.04上。然而,我不认为有什么区别。
您还没说您喂养孩子能做出什么选择

neekobn8

neekobn83#

我已经创建了一个演示应用程序s3-demo,它可以获取特定地区的bucket列表。
我也遇到了与您相同的问题(以及更多),但我最终能够编写一个构建aws-sdk-cpp和演示应用程序的Dockerfile。
这是我的Dockerfile

ARG AWS_SDK_CPP_VERSION="1.8.160"
ARG AWS_SDK_CPP_BUILD_TYPE="Release"
ARG APP_BUILD_TYPE="Release"

### -----------------------------------------------------

### Base image

### -----------------------------------------------------

FROM ubuntu:20.04 as base

# Fix tzdata hang

ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN \
    apt-get update && \
    apt-get install -y \
    curl wget git zip unzip \
    cmake g++ gcc \
    libcurl4-openssl-dev libssl-dev libpulse-dev \
    uuid-dev zlib1g-dev

RUN apt-get update && \
    apt-get install -y \
    make golang-1.13

ENV PATH="$PATH:/usr/lib/go-1.13/bin"
COPY scripts/ /usr/local/bin/
WORKDIR /code/

### -----------------------------------------------------

### Build aws-sdk-cpp

### -----------------------------------------------------

FROM base as build-aws-sdk-cpp
ARG AWS_SDK_CPP_VERSION
ARG AWS_SDK_CPP_BUILD_TYPE
ENV AWS_SDK_CPP_VERSION="${AWS_SDK_CPP_VERSION}" \
    AWS_SDK_CPP_BUILD_TYPE="${AWS_SDK_CPP_BUILD_TYPE}"
WORKDIR /code/
RUN download.sh "https://github.com/aws/aws-sdk-cpp/archive/${AWS_SDK_CPP_VERSION}.zip"
WORKDIR /sdk_build/
RUN cmake /code/aws-sdk-cpp-${AWS_SDK_CPP_VERSION} -DBUILD_ONLY="s3" -DCMAKE_BUILD_TYPE="${AWS_SDK_CPP_BUILD_TYPE}"
RUN make && \
    make install && \
    rm -rf /code/

### -----------------------------------------------------

### Build the application

### -----------------------------------------------------

FROM build-aws-sdk-cpp as build-app
WORKDIR /code/
COPY . .
ARG APP_BUILD_TYPE
ENV APP_BUILD_TYPE="${APP_BUILD_TYPE}"
RUN rm -rf build && cmake -S . -B build -DCMAKE_BUILD_TYPE="${APP_BUILD_TYPE}"
WORKDIR /code/build/
RUN make

# Default region N.Virginia
g9icjywg

g9icjywg4#

当我下载zip包的时候,我也遇到了同样的问题。后来我用git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp得到了源代码。那很好用。

相关问题