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

[package] google-cloud-cpp/1.26.1~1.31.1: Fails to compile for Windows as a DLL. #10353

Closed
hwhsu1231 opened this issue Apr 18, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@hwhsu1231
Copy link

Package and Environment Details (include every applicable attribute)

  • Package Name/Version: google-cloud-cpp/1.26.1~1.31.1
  • Operating System+version: Windows 11
  • Compiler+version: MSVC 2019
  • Docker image: None
  • Conan version: Conan 1.45.0
  • Python version: Python 3.9.2

Conan profile (output of conan profile show default)

[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
build_type=Release
[options]
[conf]
[build_requires]
[env]

Root-level CMakeLists.txt

I use CMake-Conan to install package. Here is my root-level CMakeLists.txt file:

Click to CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
get_filename_component(folder_name "${CMAKE_CURRENT_SOURCE_DIR}" NAME)
project(${folder_name} LANGUAGES C CXX)
message("========== ${folder_name} ==========")


get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
if(is_multi_config)     # Multi-Config Generator
  set(output_dir "${CMAKE_BINARY_DIR}/$<CONFIG>")
else(is_multi_config)   # Single-Config Generator
  set(output_dir "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
endif(is_multi_config)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${output_dir}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${output_dir}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${output_dir}/lib")


if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
  add_compile_options("/source-charset:utf-8")
elseif(CMAKE_CXX_COMPILER_DIR MATCHES GNU)
  add_compile_options("-finput-charset=utf-8")
endif()


if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
  message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan ...")
  file(DOWNLOAD 
    "https://raw.githubusercontent.com/conan-io/cmake-conan/develop/conan.cmake"
    "${CMAKE_BINARY_DIR}/conan.cmake")
endif()
include("${CMAKE_BINARY_DIR}/conan.cmake")


set(conan_config_generators "CMakeDeps")
set(conan_config_requires   "google-cloud-cpp/1.31.1")
set(conan_config_options    "google-cloud-cpp:shared=True")


if(is_multi_config)     # Multi-Config Generator
  foreach(type Debug;Release)
    conan_cmake_configure(
      GENERATORS  ${conan_config_generators}
      REQUIRES    ${conan_config_requires}
      OPTIONS     ${conan_config_options}
      IMPORTS     "bin, *.dll -> ../${type}/bin")
    conan_cmake_autodetect(settings BUILD_TYPE ${type})
    conan_cmake_install(
      PATH_OR_REFERENCE "."
      INSTALL_FOLDER    "./conan"
      BUILD             missing
      REMOTE            conancenter
      SETTINGS          ${settings})
  endforeach()
else(is_multi_config)   # Single-Config Generator
  set(type ${CMAKE_BUILD_TYPE})
  conan_cmake_configure(
    GENERATORS  ${conan_config_generators}
    REQUIRES    ${conan_config_requires}
    OPTIONS     ${conan_config_options}
    IMPORTS     "bin, *.dll -> ../${type}/bin")
  conan_cmake_autodetect(settings)
  conan_cmake_install(
    PATH_OR_REFERENCE "."
    INSTALL_FOLDER    "./conan"
    BUILD             missing
    REMOTE            conancenter
    SETTINGS          ${settings})
endif(is_multi_config)


list(APPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}/conan")
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/conan")

Steps to reproduce

  1. Use VSCode to open a empty folder.
  2. Download CMake-Tools plugin from Extension.
  3. Create an empty CMakeLists.txt file, and then paste the above example on it.
  4. Press Ctrl+Shift+P, and then type CMake: Configure.

Logs

Click to expand log
[cmake] ========== CMakeDeps-google-cloud-cpp ==========
[cmake] -- Downloading conan.cmake from https://github.com/conan-io/cmake-conan ...
[cmake] -- Conan: Detected VS runtime: MDd
[cmake] -- Conan: checking conan executable
[cmake] -- Conan: Found program C:/Program Files/Conan/conan/conan.exe
[cmake] -- Conan: Version found Conan version 1.45.0
[cmake] -- Conan executing: C:/Program Files/Conan/conan/conan.exe install . --remote conancenter --install-folder ./conan --build missing --settings arch=x86_64 --settings build_type=Debug --settings compiler=Visual Studio --settings compiler.version=16 --settings compiler.runtime=MDd
[cmake] Configuration:
[cmake] [settings]
[cmake] arch=x86_64
[cmake] arch_build=x86_64
[cmake] build_type=Debug
[cmake] compiler=Visual Studio
[cmake] compiler.runtime=MDd
[cmake] compiler.version=16
[cmake] os=Windows
[cmake] os_build=Windows
[cmake] [options]
[cmake] [build_requires]
[cmake] [env]
[cmake] 
[cmake] conanfile.txt: Installing package
[cmake] Requirements
[cmake]     abseil/20211102.0 from 'conancenter' - Cache
[cmake]     c-ares/1.18.1 from 'conancenter' - Cache
[cmake]     crc32c/1.1.1 from 'conancenter' - Cache
[cmake]     google-cloud-cpp/1.31.1 from 'conancenter' - Cache
[cmake]     grpc/1.39.1 from 'conancenter' - Cache
[cmake]     libcurl/7.78.0 from 'conancenter' - Cache
[cmake]     nlohmann_json/3.10.2 from 'conancenter' - Cache
[cmake]     openssl/1.1.1m from 'conancenter' - Cache
[cmake]     protobuf/3.19.2 from 'conancenter' - Cache
[cmake]     re2/20220201 from 'conancenter' - Cache
[cmake]     zlib/1.2.12 from 'conancenter' - Cache
[cmake] Packages
[cmake]     abseil/20211102.0:d057732059ea44a47760900cb5e4855d2bea8714 - Download
[cmake]     c-ares/1.18.1:54ec61be929ade75cf5113f97d6455a256d5f310 - Download
[cmake]     crc32c/1.1.1:d057732059ea44a47760900cb5e4855d2bea8714 - Download
[cmake]     google-cloud-cpp/1.31.1:INVALID - Invalid
[cmake]     grpc/1.39.1:f74385263b5bfcb37c7fad3135e62a358f333f93 - Download
[cmake]     libcurl/7.78.0:e6b1d1798581c401d12ccd0480c8dbc037628902 - Download
[cmake]     nlohmann_json/3.10.2:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Download
[cmake]     openssl/1.1.1m:d057732059ea44a47760900cb5e4855d2bea8714 - Download
[cmake]     protobuf/3.19.2:390b80578bf6c7353bb1fcd9b8fe1b4987dc6ea1 - Download
[cmake]     re2/20220201:d057732059ea44a47760900cb5e4855d2bea8714 - Download
[cmake]     zlib/1.2.12:d057732059ea44a47760900cb5e4855d2bea8714 - Download
[cmake] 
[cmake] Installing (downloading, building) binaries...
[cmake] WARN: grpc/1.39.1: requirement openssl/1.1.1n overridden by google-cloud-cpp/1.31.1 to openssl/1.1.1m 
[cmake] WARN: libcurl/7.78.0: requirement openssl/1.1.1n overridden by google-cloud-cpp/1.31.1 to openssl/1.1.1m 
[cmake] ERROR: There are invalid packages (packages that cannot exist for this configuration):
[cmake] google-cloud-cpp/1.31.1: Invalid ID: Fails to compile for Windows as a DLL
[cmake] CMake Error at build/win32-MSVC-x64-Debug/conan.cmake:651 (message):
[cmake]   Conan install failed='6'
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:64 (conan_cmake_install)
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
@hwhsu1231 hwhsu1231 added the bug Something isn't working label Apr 18, 2022
@hwhsu1231
Copy link
Author

By the way, I deleted all the source and binary packages inside their directories:

  • Binary Package: C:\.conan
  • Source Package: %USERPROFILE%\.conan\data

But it still doesn't work.

@SpaceIm
Copy link
Contributor

SpaceIm commented Apr 18, 2022

What is the issue? google-cloud-cpp as shared is not supported with VIsual Studio.

@hwhsu1231
Copy link
Author

As the log shows:

[cmake] WARN: grpc/1.39.1: requirement openssl/1.1.1n overridden by google-cloud-cpp/1.31.1 to openssl/1.1.1m 
[cmake] WARN: libcurl/7.78.0: requirement openssl/1.1.1n overridden by google-cloud-cpp/1.31.1 to openssl/1.1.1m 
[cmake] ERROR: There are invalid packages (packages that cannot exist for this configuration):
[cmake] google-cloud-cpp/1.31.1: Invalid ID: Fails to compile for Windows as a DLL

It fails to install the "google-cloud-cpp" package.

@SpaceIm
Copy link
Contributor

SpaceIm commented Apr 18, 2022

You have google-cloud-cpp:shared=True, but google-cloud-cpp shared is not supported with Visual Studio, so the recipe reports this invalid configuration, there is no issue.

@hwhsu1231
Copy link
Author

Why does google-cloud-cpp not support :shared=True option with Visual Studio, specifically? Is it normal?

@hwhsu1231 hwhsu1231 changed the title [package] google-cloud-cpp/1.26.1~1.31.1: There are invalid packages. [package] google-cloud-cpp/1.26.1~1.31.1: Fails to compile for Windows as a DLL. Apr 18, 2022
@SpaceIm
Copy link
Contributor

SpaceIm commented Apr 18, 2022

It's a google-cloud-cpp issue, not a recipe issue: https://github.com/googleapis/google-cloud-cpp/blob/main/doc/packaging.md#common-configuration-variables-for-cmake

By default, CMake compiles the google-cloud-cpp as static libraries. The standard -DBUILD_SHARED_LIBS=ON option can be used to switch this to shared libraries. Having said this, on Windows there are googleapis/google-cloud-cpp#5849 with DLLs and generated protos.

@jgsogo
Copy link
Contributor

jgsogo commented May 5, 2022

As said in previous comments, it is not an error/bug. The recipe is managing this configuration and reporting that the package cannot exist for that configuration.

ERROR: There are invalid packages (packages that cannot exist for this configuration):
google-cloud-cpp/1.31.1: Invalid ID: Fails to compile for Windows as a DLL

This is one of the value propositions of Conan: to inform the user about invalid builds in advance, no need to wait for actual compiler/linker to report a long and unintelligible error.

Closing this issue, please read previous comments for more information from GCP itself about known issues related to that configuration.

Thanks!

@jgsogo jgsogo closed this as completed May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants