Hello everyone,

I'm having issue while trying to build a minimal c++ grpc application using 
vcpkg as package manager and cmake to build the app.

The issue happens during link with an unresolved external:

grpc.lib(uri.cc.obj) : error LNK2019: unresolved external symbol 
__std_find_first_of_trivial_pos_1 referenced in function "unsigned __int64 
__cdecl std::_Find_first_of_pos_vectorized<char,char>(char const * 
const,unsigned __int64,char const * const,unsigned __int64)" 
(??$_Find_first_of_pos_vectorized@DD@std@@YA_KQEBD_K01@Z)

It happens if I try to build a simple proto file.

This is my cmakelists.txt:

cmake_minimum_required(VERSION 3.22)

project(it-dms-injection)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED True)

if(MSVC)
    add_definitions(-D_WIN32_WINNT=0x0600)
endif()

find_package(Protobuf CONFIG REQUIRED)
find_package(grpc CONFIG REQUIRED)

add_executable(it-dms-injection 
    proto/route_guide.proto
main.cpp 
)

target_include_directories(it-dms-injection PRIVATE 
${CMAKE_CURRENT_BINARY_DIR})

set(PROTO_FILES
    proto/route_guide.proto
)

protobuf_generate(
    TARGET it-dms-injection
    LANGUAGE cpp
    PROTOS ${PROTO_FILES}
    IMPORT_DIRS proto
)

# Custom command to generate gRPC sources
foreach(proto ${PROTO_FILES})
    get_filename_component(proto_name ${proto} NAME_WE)

    set(grpc_src "${CMAKE_CURRENT_BINARY_DIR}/${proto_name}.grpc.pb.cc")
    set(grpc_hdr "${CMAKE_CURRENT_BINARY_DIR}/${proto_name}.grpc.pb.h")

    add_custom_command(
        OUTPUT ${grpc_src} ${grpc_hdr}
        COMMAND protobuf::protoc
        ARGS --grpc_out=${CMAKE_CURRENT_BINARY_DIR}
             --cpp_out=${CMAKE_CURRENT_BINARY_DIR}
             -I ${CMAKE_CURRENT_SOURCE_DIR}/proto
             --plugin=protoc-gen-grpc=$<TARGET_FILE:gRPC::grpc_cpp_plugin>
             ${CMAKE_CURRENT_SOURCE_DIR}/${proto}   # FIXED LINE
        DEPENDS ${proto}
    )

    list(APPEND GRPC_SRCS ${grpc_src})
    list(APPEND GRPC_HDRS ${grpc_hdr})
endforeach()

target_sources(it-dms-injection PRIVATE ${GRPC_SRCS} ${GRPC_HDRS})

target_link_libraries(it-dms-injection PRIVATE     
protobuf::libprotobuf
    gRPC::gpr 
gRPC::grpc 
gRPC::grpc++ 
gRPC::grpc++_alts
)

and I'm using VS 2022 version 17.14.0.

Does any of you is experiencing a similar issue?

Thanks,
Guglielmo


-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/grpc-io/2166a5d8-30f2-4336-bdc7-b9c39e096acbn%40googlegroups.com.

Reply via email to