宇宙的尽头是编制 2022-05-01 09:21 采纳率: 0%
浏览 295
已结题

QtCreator grpc Demo编译不过

问题遇到的现象和发生背景

因项目需要,需要用到GRPC,于是研究了下,编译源码也挺费劲,但还好,也顺利编译完成,并且成功编译通过VS2019 Qt 工程。
VS2019 Qt工程 : https://gitee.com/lanzhou-lezhi_0/window-grpc-qt-vs2019
但是,但是QtCreator创建的工程在_Windows,Linux_系统都编译不过。迟迟未能解决,特发帖,请求各位网友帮忙解决
QtCreator工程:https://gitee.com/lanzhou-lezhi_0/grpc-qt-demo-qt-creator

问题相关代码,请勿粘贴截图
工程文件一览:
  helloworld.grpc.pb.h
  helloworld.pb.cc
  helloworld.pb.h
  helloworld.grpc.pb.cc
  client/greeter_client.cc

grpc sdk一览:
bin文件:

grpc_csharp_plugin.exe
grpc_node_plugin.exe
grpc_objective_c_plugin.exe
grpc_php_plugin.exe
grpc_python_plugin.exe
grpc_ruby_plugin.exe
protoc.exe
zlibd.dll
acountry.exe
adig.exe
ahost.exe
grpc_cpp_plugin.exe

lib文件一览:

img


pro工程文件一览,将所有的lib文件全部包含了。由于字数限制,只是列出来了部分pro文件,全部pro文件请查看:
https://gitee.com/lanzhou-lezhi_0/grpc-qt-demo-qt-creator/blob/master/client-demo.pro

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += _WIN32_WINNT=0x600

SRC_PATH = $${PWD}/client
win32: GRPC_SDK_PATH = $${PWD}/grpc-windows-sdk
else:unix: GRPC_SDK_PATH = $${PWD}/grpc-linux-sdk

INCLUDEPATH += $${GRPC_SDK_PATH}/include
DEPENDPATH += $${GRPC_SDK_PATH}/include

SOURCES += \
  $${SRC_PATH}/greeter_client.cc \
  $${SRC_PATH}/../helloworld.grpc.pb.cc \
  $${SRC_PATH}/../helloworld.pb.cc

HEADERS += \
  $${SRC_PATH}/../helloworld.grpc.pb.h \
  $${SRC_PATH}/../helloworld.pb.h

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lcares
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lcares
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lcares

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libcares.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libcares.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/cares.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/cares.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libcares.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lcrypto
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lcrypto
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lcrypto

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libcrypto.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libcrypto.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/crypto.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/crypto.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libcrypto.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lgpr
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lgpr
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lgpr

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libgpr.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libgpr.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/gpr.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/gpr.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libgpr.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lgrpc
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lgrpc
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lgrpc

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libgrpc.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libgrpc.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/grpc.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/grpc.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libgrpc.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lgrpc_plugin_support
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lgrpc_plugin_support
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lgrpc_plugin_support

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libgrpc_plugin_support.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libgrpc_plugin_support.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/grpc_plugin_support.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/grpc_plugin_support.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libgrpc_plugin_support.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lgrpc_unsecure
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lgrpc_unsecure
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lgrpc_unsecure

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libgrpc_unsecure.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libgrpc_unsecure.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/grpc_unsecure.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/grpc_unsecure.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libgrpc_unsecure.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lgrpc++
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lgrpc++
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lgrpc++

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libgrpc++.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libgrpc++.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/grpc++.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/grpc++.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libgrpc++.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lgrpc++_alts
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lgrpc++_alts
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lgrpc++_alts

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libgrpc++_alts.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libgrpc++_alts.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/grpc++_alts.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/grpc++_alts.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libgrpc++_alts.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lgrpc++_error_details
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lgrpc++_error_details
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lgrpc++_error_details

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libgrpc++_error_details.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libgrpc++_error_details.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/grpc++_error_details.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/grpc++_error_details.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libgrpc++_error_details.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lgrpc++_reflection
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lgrpc++_reflection
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lgrpc++_reflection

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libgrpc++_reflection.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libgrpc++_reflection.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/grpc++_reflection.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/grpc++_reflection.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libgrpc++_reflection.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lgrpc++_unsecure
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lgrpc++_unsecure
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lgrpc++_unsecure

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libgrpc++_unsecure.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libgrpc++_unsecure.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/grpc++_unsecure.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/grpc++_unsecure.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libgrpc++_unsecure.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lgrpcpp_channelz
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lgrpcpp_channelz
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lgrpcpp_channelz

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libgrpcpp_channelz.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libgrpcpp_channelz.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/grpcpp_channelz.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/grpcpp_channelz.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libgrpcpp_channelz.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -llibprotobuf
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -llibprotobufd
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lprotobuf

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/liblibprotobufd.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/liblibprotobufd.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libprotobuf.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libprotobufd.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libprotobuf.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -llibprotobuf-lite
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -llibprotobuf-lited
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lprotobuf-lite

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/liblibprotobuf-lited.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/liblibprotobuf-lited.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libprotobuf-lite.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libprotobuf-lited.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libprotobuf-lite.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -llibprotoc
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -llibprotocd
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lprotoc

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/liblibprotocd.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/liblibprotocd.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libprotoc.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libprotocd.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libprotoc.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lre2
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lre2
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lre2

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libre2.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libre2.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/re2.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/re2.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libre2.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lssl
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lssl
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lssl

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libssl.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libssl.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/ssl.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/ssl.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libssl.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lupb
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lupb
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lupb

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libupb.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libupb.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/upb.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/upb.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libupb.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lzlib
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lzlibd
else:unix: LIBS += -L$${GRPC_SDK_PATH}/lib/ -lz

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libzlib.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libzlibd.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/zlib.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/zlibd.lib
else:unix: PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/libz.a

win32:CONFIG(release, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/release/ -lzlibstatic
else:win32:CONFIG(debug, debug|release): LIBS += -L$${GRPC_SDK_PATH}/lib/debug/ -lzlibstaticd

win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/libzlibstatic.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/libzlibstaticd.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/release/zlibstatic.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $${GRPC_SDK_PATH}/lib/debug/zlibstaticd.lib
运行结果及报错内容
grpc.lib(rls.obj):-1: error: LNK2001: 无法解析的外部符号 "private: static unsigned __int64 __cdecl absl::lts_20211102::hash_internal::MixingHashState::CombineLargeContiguousImpl64(unsigned __int64,unsigned char const *,unsigned __int64)" 
grpc.lib(rls.obj):-1: error: LNK2019: 无法解析的外部符号 "private: static void const * const absl::lts_20211102::hash_internal::MixingHashState::kSeed" (?kSeed@MixingHashState@hash_internal@lts_20211102@absl@@0QEBXEB),函数 "public: unsigned __int64 __cdecl std::_Uhash_compare<struct grpc_core::`anonymous namespace'::RlsLb::RequestKey,struct absl::lts_20211102::hash_internal::Hash<struct grpc_core::`anonymous namespace'::RlsLb::RequestKey>,struct std::equal_to<struct grpc_core::`anonymous namespace'::RlsLb::RequestKey> >::operator()<struct grpc_core::`anonymous namespace'::RlsLb::RequestKey>(struct grpc_core::`anonymous namespace'::RlsLb::RequestKey const &)
release\client-demo.exe:-1: error: LNK1120: 2 个无法解析的外部命令
我的解答思路和尝试过的方法

网上有人说是grpc.lib库编译有问题,我也不敢苟同,因为VS2019工程也使用了同样的一套库文件,确实可以正常编译,并且Server ,client可以正常helloworld通信,仅仅只是换了工程,就编译过不,所以我认为问题出在pro文件上,还请各位网友帮忙解决。

我想要达到的结果

@一去丶二三里
@Tjmies

  • 写回答

1条回答 默认 最新

  • 宇宙的尽头是编制 2022-05-05 15:22
    关注

    该问题历时一周,终于自己解决了。现在把解决思路及Demo分享一下.
    通过查阅grpc helloworld Makefile,发现通过pkg-config,系统可自动去关联相关依赖库,比我们自己添加依赖库要方便。整理为:
    1、编译openssl源码,生成openssl库文件。包括了bin,include,lib等文件。重要的地方来了,将lib文件夹下pkgconfig添加到系统PKG_CONFIG_PATH环境变量中去。
    2、编译grpc源码,openssl为package. 在执行cmake时,会自动查找到libcrypto.so等依赖库。生成grpc库文件。同样包含了bin,include,lib等文件。将lib文件夹下pkgconfig添加到系统PKG_CONFIG_PATH环境变量中去。
    至此,grpc环境已经搭建完毕。
    3、去编写pro文件,此时就来的非常的简单。

    QMAKE_CFLAGS = `pkg-config --cflags protobuf grpc`
    QMAKE_CXXFLAGS += $$QMAKE_CFLAGS
     
    CONFIG += link_pkgconfig
    PKGCONFIG += protobuf grpc++
    

    至此,搞定。编译就可以了。
    PKG_CONFIG_PATH系统环境变量的添加,请参考:demo ReadMe
    demo已上传至gitee:https://gitee.com/lanzhou-lezhi_0/grpc-qt-demo-qt-creator

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 5月13日
  • 已采纳回答 5月5日
  • 修改了问题 5月1日
  • 修改了问题 5月1日
  • 展开全部

悬赏问题

  • ¥25 C语言代码,大家帮帮我
  • ¥15 请问以下文字内容及对应编码是用了什么加密算法或压缩算法呢?
  • ¥50 关于#html5#的问题:H5页面用户手机返回的时候跳转到指定页面例如(语言-javascript)
  • ¥15 无法使用此凭据登录,因为你的域不可用,如何解决?(标签-Windows)
  • ¥15 yolov9的训练时间
  • ¥15 二叉树遍历没有报错但无法正常运行
  • ¥15 在linux系统下vscode运行robocup3d上场球员报错
  • ¥15 Python语言实验
  • ¥15 SAP HANA SQL 增加合计行
  • ¥20 用C#语言解决一个英文打字练习器,有偿