无法 link 对抗 grpc conan

Cannot link against grpc conan

我尝试构建默认的 hello world (https://github.com/grpc/grpc/tree/master/examples/cpp/helloworld) grpc 示例,但使用的是 conan grpc。 我修改了 cmakelists:

# Copyright 2018 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# cmake build file for C++ helloworld example.
# Assumes protobuf and gRPC have been installed using cmake.
# See cmake_externalproject/CMakeLists.txt for all-in-one cmake build
# that automatically builds all the dependencies before building helloworld.

cmake_minimum_required(VERSION 3.13)

project(HelloWorld C CXX)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include(${CMAKE_CURRENT_SOURCE_DIR}/conanbuildinfo.cmake)

conan_basic_setup(TARGETS)

find_package(Protobuf REQUIRED)
#find_package(CONAN_PKG::grpc REQUIRED)
# Proto file
get_filename_component(hw_proto "../../protos/helloworld.proto" NAME        )
get_filename_component(hw_proto_path "${hw_proto}" PATH)
# Generated sources grpc_cpp_plugin

# Add Library target with protobuf sources
add_library(hw_grpc_proto ${hw_proto} ${hw_grpc_srcs} ${hw_grpc_hdrs})
message(STATUS plugins ${CONAN_BIN_DIRS_GRPC})
message(STATUS proto ${hw_proto})
set(hw_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.cc")
set(hw_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.h")
set(hw_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.cc")
set(hw_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.h")
set(hw_grpc_proto_PROTOS ${hw_proto})
set(grpc_cpp_plugin_location ${CONAN_BIN_DIRS_GRPC}/grpc_cpp_plugin)
message(STATUS grpc-plugin ${grpc_cpp_plugin_location})
protobuf_generate(TARGET hw_grpc_proto LANGUAGE cpp ${hw_proto_srcs} ${hw_proto_hdrs})
#protobuf_generate(TARGET hw_grpc_proto LANGUAGE grpc GENERATE_EXTENSIONS ${hw_grpc_srcs} ${hw_grpc_hdrs} PLUGIN "protoc-gen-grpc=${grpc_cpp_plugin_location}")

message(STATUS ${Protobuf_PROTOC_EXECUTABLE})
add_custom_command(
      OUTPUT "${hw_grpc_srcs}" "${hw_grpc_hdrs}"
      COMMAND ${Protobuf_PROTOC_EXECUTABLE}
      ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
        --cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
        -I "${hw_proto_path}"
        --plugin=protoc-gen-grpc="${grpc_cpp_plugin_location}"
        "${hw_proto}"
      DEPENDS "${hw_proto}")

# Include generated *.pb.h files


# hw_grpc_proto

target_link_libraries(hw_grpc_proto
  CONAN_PKG::grpc
  CONAN_PKG::protobuf
  )

# Targets greeter_[async_](client|server)
foreach(_target
  greeter_client greeter_server
  greeter_async_client greeter_async_client2 greeter_async_server)
  add_executable(${_target} "${_target}.cc")
  target_link_libraries(${_target}
    CONAN_PKG::grpc
    CONAN_PKG::protobuf
    hw_grpc_proto
    )
endforeach()

hw_grpc_proto 已构建,但在 linking 可执行文件上失败。 https://pastebin.com/3udDc68a(此处限制为 30k 个符号)

我使用带有此选项的 conan 包

[settings]
    arch=x86_64
    build_type=Release
    compiler=gcc
    compiler.libcxx=libstdc++
    compiler.version=8
    os=Linux

在我的 debian buster 上使用 gcc 8.3.0 和 libstdc++6 我看到它必须 link 针对 protobuf 和 grpc 但它失败了。

这是答案 我真的不知道为什么柯南包含遗留 gcc 的 protobuf 并且没有关于这个的信息