aws-sdk-cpp
aws-sdk-cpp copied to clipboard
find_package(AWSSDK) fails Linux
Describe the bug
When I use
FIND_PACKAGE(AWSSDK REQUIRED COMPONENTS polly HINTS /aws-install-path NO_CMAKE_FIND_ROOT_PATH)
It fails with
By not providing "Findaws-cpp-sdk-core.cmake" in CMAKE_MODULE_PATH this
[cmake] project has asked CMake to find a package configuration file provided by
[cmake] "aws-cpp-sdk-core", but CMake did not find one.
Expected Behavior
Should find all components.
Current Behavior
[cmake] -- Found AWS SDK for C++, Version: 1.9.230, Install Root:/home/USER/Desktop/Projects/External/local/Linux_x86_64_Release_Native, Platform Prefix:, Platform Dependent Libraries: pthread;crypto;ssl;z;curl
[cmake] -- Components specified for AWSSDK: polly, application will be depending on libs: aws-cpp-sdk-polly;aws-cpp-sdk-core;aws-crt-cpp;aws-c-auth;aws-c-cal;aws-c-common;aws-c-compression;aws-c-event-stream;aws-c-http;aws-c-io;aws-c-mqtt;aws-c-s3;aws-checksums;pthread;crypto;ssl;z;curl
[cmake] -- Try finding aws-cpp-sdk-core
[cmake] CMake Error at /home/USER/Desktop/Projects/External/local/Linux_x86_64_Release_Native/lib/cmake/AWSSDK/AWSSDKConfig.cmake:307 (find_package):
[cmake] By not providing "Findaws-cpp-sdk-core.cmake" in CMAKE_MODULE_PATH this
[cmake] project has asked CMake to find a package configuration file provided by
[cmake] "aws-cpp-sdk-core", but CMake did not find one.
[cmake]
[cmake] Could not find a package configuration file provided by "aws-cpp-sdk-core"
[cmake] with any of the following names:
[cmake]
[cmake] aws-cpp-sdk-coreConfig.cmake
[cmake] aws-cpp-sdk-core-config.cmake
[cmake]
[cmake] Add the installation prefix of "aws-cpp-sdk-core" to CMAKE_PREFIX_PATH or
[cmake] set "aws-cpp-sdk-core_DIR" to a directory containing one of the above
[cmake] files. If "aws-cpp-sdk-core" provides a separate development package or
[cmake] SDK, be sure it has been installed.
[cmake] Call Stack (most recent call first):
[cmake] CMakeLists.txt:179 (FIND_PACKAGE)
Reproduction Steps
Build aws-sdk via cmake:
-
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_PREFIX_PATH=/local -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/local -Bbuild -Hsrc -DBUILD_ONLY=polly
-
cmake --build build --config Release
-
cmake --install build
Possible Solution
The solution is:
SET(CMAKE_PREFIX_PATH /aws-install-path)
However I tried many things in order to figure this out...This SHOULD be stated in the docs. It's not on github Docs and it's not on AWS docs! Wasted two days trying to figure this out. Also even though this is a solution there are many other ways this should work but it doesn't such as the way I was trying:
FIND_PACKAGE(AWSSDK REQUIRED COMPONENTS polly HINTS /aws-install-path NO_CMAKE_FIND_ROOT_PATH)
Furthermore this message by CMAKE is misleading and incorrect:
[cmake] Add the installation prefix of "aws-cpp-sdk-core" to CMAKE_PREFIX_PATH or
In fact doing so doesn't work as the directory of aws-cpp-sdk-core is a subdir of the aws-install-path.
Additional Information/Context
I tried setting CMAKE_MODULES_PATH and CMAKE_PREFIX, neither worked.
AWS CPP SDK version used
Found AWS SDK for C++, Version: 1.9.230
Compiler and Version used
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Operating System and version
Linux i7 5.4.0-107-generic #121-Ubuntu SMP Thu Mar 24 16:04:27 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Thanks for pointing this out. We will look into adding this to our documentation.
Had the same issue. Similarly as the author, I tried many different things, but all failed. The solution provided here worked perfectly... SET(CMAKE_PREFIX_PATH /aws-install-path)
@ambitslix thanks!
Just add -DCMAKE_PREFIX_PATH=/where/awssdk/was/installed
when calling cmake.
It is a built-in cmake variable intended specifically for this.
I just struggled with this, I've been trying to build this example https://github.com/awslabs/aws-lambda-cpp/tree/master/examples/api-gateway
here is the CMakeLists.txt file that finally made it work: `
cmake_minimum_required(VERSION 3.13) # CMake version check
set(CMAKE_CXX_STANDARD 17) # Enable c++14 standard
project(my-aws-lambda LANGUAGES CXX)
SET(CMAKE_PREFIX_PATH /usr/local/aws/sdk)
set(aws-lambda-runtime_DIR /usr/local/aws/runtime/lib/aws-lambda-runtime/cmake/)
set(AWSSDK_DIR /usr/local/aws/sdk/lib/cmake/AWSSDK/)
find_package(aws-lambda-runtime REQUIRED)
find_package(AWSSDK COMPONENTS core)
add_executable(${PROJECT_NAME} "lambda/main.cpp")
target_link_libraries(${PROJECT_NAME} PUBLIC AWS::aws-lambda-runtime ${AWSSDK_LINK_LIBRARIES})
target_compile_features(${PROJECT_NAME} PRIVATE "cxx_std_17")
target_compile_options(${PROJECT_NAME} PRIVATE "-Wall" "-Wextra")
# this line creates a target that packages your binary and zips it up
aws_lambda_package_target(${PROJECT_NAME})
`
/usr/local/aws/runtime
is the install directory of the lambda runtime
/usr/local/aws/sdk
is the install directory of the SDK
note the example https://github.com/awslabs/aws-lambda-cpp used target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-lambda-runtime)
instead of target_link_libraries(${PROJECT_NAME} PUBLIC AWS::aws-lambda-runtime ${AWSSDK_LINK_LIBRARIES})
and it did not work
Just an observation, the standard /usr/local
system directory is meant to directly contain standard subdirectories such as bin
, lib
, include
, etc., and so it makes more sense to install directly into /usr/local
rather create an aws
subdirectory alongside the other directories inside /usr/local
.
If you don't mind installing into /usr/local
, then the workflow is simpler if you install both the SDK and runtime with -DCMAKE_INSTALL_PREFIX=/usr/local
. CMake should then find everything automatically.
If you want to install the SDK and runtime somewhere else, you could try -DCMAKE_INSTALL_PREFIX=/opt/aws
(this is precisely what /opt
is for) and then specify set(CMAKE_PREFIX_PATH /opt/aws)
in CMakeLists.txt
, although it's probably more fitting to pass -DCMAKE_PREFIX_PATH=/opt/aws
when running cmake
, since it corresponds to how the installation directory is specified when installing those libraries.
Can you try fixing this typo in your cmake command and see if you are still getting this issue? It should be:
-DCMAKE_INSTALL_PREFIX_PATH
and not:
-DCMAKE_INSTALL_PREFIX:PATH
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.