首页 > 解决方案 > 如何在 C++ 中成功构建 gRPC?

问题描述

我正在尝试按照c++ gRPC 安装在 C++ 中构建 gRPC 。我的操作系统是安装在 Raspberry Pi 4 上的 Ubuntu20.4 LTS。

当我输入这个命令“make -j”

$ cd grpc
$ mkdir -p cmake/build
$ pushd cmake/build
$ cmake -DgRPC_INSTALL=ON \
      -DgRPC_BUILD_TESTS=OFF \
      -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR \
      ../..
$ make -j

发生此错误。

[  1%] Built target zlibstatic
・
・
[ 97%] Built target mimics_pcre_test
[ 97%] Built target possible_match_test
[ 97%] Built target set_test
[ 97%] Built target regexp_test
[ 97%] Built target search_test
[ 97%] Linking CXX executable bssl
/usr/bin/ld: CMakeFiles/bssl.dir/src/tool/transport_common.cc.o: in function `PrintConnectionInfo(bio_st*, ssl_st const*)':
transport_common.cc:(.text+0xd40): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: transport_common.cc:(.text+0xd74): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: libcrypto.a(trust_token.c.o):(.data.rel.ro+0x50): undefined reference to `voprf_exp2_generate_key'
/usr/bin/ld: libcrypto.a(trust_token.c.o):(.data.rel.ro+0x58): undefined reference to `voprf_exp2_client_key_from_bytes'
/usr/bin/ld: libcrypto.a(trust_token.c.o):(.data.rel.ro+0x60): undefined reference to `voprf_exp2_issuer_key_from_bytes'
/usr/bin/ld: libcrypto.a(trust_token.c.o):(.data.rel.ro+0x68): undefined reference to `voprf_exp2_blind'
/usr/bin/ld: libcrypto.a(trust_token.c.o):(.data.rel.ro+0x70): undefined reference to `voprf_exp2_sign'
/usr/bin/ld: libcrypto.a(trust_token.c.o):(.data.rel.ro+0x78): undefined reference to `voprf_exp2_unblind'
/usr/bin/ld: libcrypto.a(trust_token.c.o):(.data.rel.ro+0x80): undefined reference to `voprf_exp2_read'
/usr/bin/ld: libcrypto.a(x509_vfy.c.o): in function `reject_dns_name_in_common_name':
x509_vfy.c:(.text+0x16dc): undefined reference to `ASN1_STRING_to_UTF8'
/usr/bin/ld: libcrypto.a(x_name.c.o): in function `asn1_string_canon':
x_name.c:(.text+0xe94): undefined reference to `ASN1_STRING_to_UTF8'
/usr/bin/ld: libcrypto.a(v3_crld.c.o): in function `print_distpoint':
v3_crld.c:(.text+0x1304): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: libcrypto.a(v3_utl.c.o): in function `do_check_string':
v3_utl.c:(.text+0x288c): undefined reference to `ASN1_STRING_to_UTF8'
/usr/bin/ld: libcrypto.a(algorithm.c.o): in function `x509_digest_sign_algorithm':
algorithm.c:(.text+0xac): undefined reference to `x509_rsa_ctx_to_pss'
/usr/bin/ld: libcrypto.a(algorithm.c.o): in function `x509_digest_verify_init':
algorithm.c:(.text+0x2c4): undefined reference to `x509_rsa_pss_to_ctx'
/usr/bin/ld: libcrypto.a(v3_alt.c.o): in function `GENERAL_NAME_print':
v3_alt.c:(.text+0x7c4): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: libcrypto.a(t_x509.c.o): in function `X509_print_ex':
t_x509.c:(.text+0x404): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: t_x509.c:(.text+0x52c): undefined reference to `X509_NAME_print_ex'
/usr/bin/ld: libcrypto.a(t_x509.c.o): in function `X509_signature_print':
t_x509.c:(.text+0xb7c): undefined reference to `x509_print_rsa_pss_params'
collect2: error: ld returned 1 exit status
make[2]: *** [third_party/boringssl-with-bazel/CMakeFiles/bssl.dir/build.make:339: third_party/boringssl-with-bazel/bssl] Error 1
make[1]: *** [CMakeFiles/Makefile2:4800: third_party/boringssl-with-bazel/CMakeFiles/bssl.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

请帮我解决这个问题。

标签: c++grpc

解决方案


你能显示gRPC_SSL_PROVIDER变量有什么值吗?如果有,则只需初始化子模块并使用(参阅module)进行构建。另一种选择,您可以使用 构建,只需设置.BoringSSLOpenSSL-DgPRC_SSL_PROVIDER=package


推荐阅读