0

i tried to build default hello world (https://github.com/grpc/grpc/tree/master/examples/cpp/helloworld) grpc example but with conan grpc. I reworked 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 has been built but it fails on linking executables. https://pastebin.com/3udDc68a ( here is limit 30k symbols)

I use conan package with this options

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

on my debian buster with gcc 8.3.0 and libstdc++6 I see it have to link against protobuf and grpc but it fails.

MoonRaiser
  • 123
  • 13

1 Answers1

0

Here is answer https://stackoverflow.com/a/30175210/8524139 I really dont know why conan contains protobuf for legacy gcc and there is nowhere information about this

MoonRaiser
  • 123
  • 13