microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.99k stars 6.35k forks source link

[aws-cpp-sdk] "AWS SDK for C++ is missing, please install it first" after installation #24472

Closed TheSharpOwl closed 1 year ago

TheSharpOwl commented 2 years ago

Describe the bug Inside [VCPKG_LOCATION]\vcpkg\installed\x64-windows\share\AWSSDK\AWSSDKConfig.cmake (for me I am using x64-windows build but I remember the same issue with static one). There are 2 problems:

  1. These lines cannot find the header
    if (AWSSDK_ROOT_DIR)
    find_file(AWSSDK_CORE_HEADER_FILE Aws.h
            "${AWSSDK_ROOT_DIR}/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
            "${AWSSDK_DEFAULT_ROOT_DIR}/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
            )
    else()
    find_file(AWSSDK_CORE_HEADER_FILE Aws.h
        "${AWSSDK_DEFAULT_ROOT_DIR}/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
        "/usr/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
        "/usr/local/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
        "C:/Progra~1/AWSSDK/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
        "C:/Program Files/AWSSDK/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
        "C:/Program Files/aws-cpp-sdk-all/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
        "C:/Program Files (x86)/aws-cpp-sdk-all/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
        "C:/AWSSDK/${AWSSDK_INSTALL_INCLUDEDIR}/aws/core"
    )
    endif()

    which takes it directly to the next lines printing that:

    if (NOT AWSSDK_CORE_HEADER_FILE)
    message(FATAL_ERROR "AWS SDK for C++ is missing, please install it first")
    endif()
  2. These lines cannot find the lib file: (because I added the directory containing the header manually and ran into this after)
    find_library(AWSSDK_CORE_LIB_FILE aws-cpp-sdk-core
        "${AWSSDK_ROOT_DIR}/${AWSSDK_INSTALL_LIBDIR}/${AWSSDK_PLATFORM_PREFIX}"
        "${AWSSDK_ROOT_DIR}/${AWSSDK_INSTALL_LIBDIR}/${AWSSDK_PLATFORM_PREFIX}/Debug"
        "${AWSSDK_ROOT_DIR}/${AWSSDK_INSTALL_LIBDIR}/${AWSSDK_PLATFORM_PREFIX}/DebugOpt"
        "${AWSSDK_ROOT_DIR}/${AWSSDK_INSTALL_LIBDIR}/${AWSSDK_PLATFORM_PREFIX}/Release"
        "${AWSSDK_ROOT_DIR}/${AWSSDK_INSTALL_LIBDIR}/${AWSSDK_PLATFORM_PREFIX}/RelWithDebInfo"
        "${AWSSDK_ROOT_DIR}/${AWSSDK_INSTALL_LIBDIR}/${AWSSDK_PLATFORM_PREFIX}/MinSizeRel"
        NO_DEFAULT_PATH)

    which takes it to print this (in the lines next)

    if (NOT AWSSDK_CORE_LIB_FILE)
    message(FATAL_ERROR "AWS SDK for C++ headers found, but we were unable to locate the binaries. Have you deleted or moved it?
            Please make sure header files and binaries are located in INSTALL_ROOT_DIR/INCLUDE_DIR/ and INSTALL_ROOT_DIR/LIB_DIR/[PLATFORM_PREFIX]/[Debug|Config|OtherConfigs]")
    endif()

Link to the file in the aws-cpp-sdk repo

Environment

To Reproduce Steps to reproduce the behavior:

  1. ./vcpkg.exe install aws-sdk-cpp[s3]:x64-windows
  2. Make any project with a CMake containing: find_package(AWSSDK CONFIG REQUIRED COMPONENTS s3) (It should be the same problem without specifying COMPONENTS but reporting exactly what happened to me)

Expected behavior CMake output:

CMake Error at [vpkg_installation_path]/vcpkg/installed/x64-windows/share/AWSSDK/AWSSDKConfig.cmake:108 (message):
  AWS SDK for C++ is missing, please install it first

Failure logs None it's the cmake output only

Additional context I noticed also that AWSSDK_PLATFORM_PREFIX CMake variable is empty Also what I think could fix it: Maybe some CMake variables they used can be set such that one of the options written in find_file would be parsed to the path containing the header and the lib file (also attention should be paid to cases of windows-x64 or windows-x64-static to have different values for CMake variables according to the chosen installed version with vcpkg

Fix for now: Specify the path yourself example for me:

  1. In the header find file (first one) I added this option too: "[installation_path_for_vcpkg]/vcpkg/installed/x64-windows/include/aws/core"
  2. In the lib find file part I added this option too: "[installation_path_for_vcpkg]/vcpkg/installed/x64-windows/debug/lib"

Also don't forget to change the x64-windows part if you use another one and release be added the same way for the library part.

JackBoosY commented 2 years ago

cc @camarois

LilyWangLL commented 1 year ago

Thanks for posting this issue. This issue has been fixed now, you can use aws-sdk-cpp in your project.

  1. Installing aws-sdk-cpp by vcpkg.

    Elapsed time to handle aws-sdk-cpp:x64-windows: 4.812 min
    Total install time: 7.201 min
    The package aws-sdk-cpp:x64-windows provides CMake targets:
    
    When using AWSSDK, AWSSDK_ROOT_DIR must be defined by the user.
    find_package(AWSSDK CONFIG COMPONENTS core dynamodb kinesis s3 REQUIRED)
    target_include_directories(main PRIVATE ${AWSSDK_INCLUDE_DIRS})
    target_link_libraries(main PRIVATE ${AWSSDK_LIBRARIES})
    
    OR
    
    find_package(aws-cpp-sdk-core REQUIRED)
    target_include_directories(main PRIVATE aws-cpp-sdk-core)
    target_link_libraries(main PRIVATE aws-cpp-sdk-core)
  2. Use find_package(AWSSDK CONFIG COMPONENTS core dynamodb kinesis s3 REQUIRED) in CMake project, and all header files could be included in project correctly.
    1> [CMake] -- Found Threads: TRUE  
    1> [CMake] -- Found aws-cpp-sdk-core
    1> [CMake] -- Try finding aws-cpp-sdk-s3
    1> [CMake] -- Found aws-cpp-sdk-s3
    1> [CMake] -- Try finding aws-cpp-sdk-kinesis
    1> [CMake] -- Found aws-cpp-sdk-kinesis
    1> [CMake] -- Try finding aws-cpp-sdk-dynamodb
    1> [CMake] -- Found aws-cpp-sdk-dynamodb
    1> [CMake] -- Configuring done
    1> [CMake] -- Generating done