grpc在centos6.9下编译

环境准备

grpc: 1.43.2
gcc: 9.3.0
openssl: 1.0.1

开始编译

grpc默认使用的boringssl不能在centos6上旧版本ld中链接通过,需要使用openssl 1.0以上的库替换
操作方式:
1.准备编译好的openssl库

2.修改根目录下的CMakeLists.txt,增加内容:

set(CMAKE_CXX_STANDARD 11)
include_directories(<openssl_dir>/include)
link_directories(<openssl_dir>/lib)

3.修改third_party/abseil-cpp/CMakeLists.txt 在cmake_minimum_required(VERSION 3.5) 下一行添加set(CMAKE_CXX_STANDARD 11),使用c++11标准编译,兼容性更高。

4.执行命令

export LDFLAGS=-lrt
mkdir build
cd build
cmake ..
make -j20
cmake .. -DCMAKE_INSTALL_PREFIX=~/grpc -DgRPC_SSL_PROVIDER=OpenSSL

链接选项:

-L/home/xxx/dev_tools/grpc/lib64  -L/home/xxx/dev_tools/grpc/lib  -L/home/xxx/.local/lib -Wl,-rpath,/home/xxx/dev_tools/grpc/lib64:/home/xxx/dev_tools/grpc/lib:/home/xxx/.local/lib libhw_grpc_proto.a -lssl -lcrypto -lgrpc++_reflection -lgrpc++ -lprotobuf -lgrpcpp_channelz -lgrpc -lrt -lgrpc++_unsecure -lgrpc_unsecure -lgrpc++ -lupb -lgrpc++_error_details -lgrpc++_reflection -lgpr -lre2 -lcares -lgrpc_plugin_support -lz -laddress_sorting -lgrpc++_alts -labsl_throw_delegate -labsl_flags_commandlineflag_internal -labsl_flags -labsl_low_level_hash -labsl_flags_commandlineflag -labsl_leak_check_disable -labsl_str_format_internal -labsl_flags_parse -labsl_bad_optional_access -labsl_strings_internal -labsl_spinlock_wait -labsl_stacktrace -labsl_cord -labsl_malloc_internal -labsl_exponential_biased -labsl_bad_any_cast_impl -labsl_cordz_info -labsl_flags_usage -labsl_examine_stack -labsl_base -labsl_flags_usage_internal -labsl_bad_variant_access -labsl_random_internal_randen_hwaes_impl -labsl_flags_program_name -labsl_flags_marshalling -lprotobuf-lite -labsl_scoped_set_env -lprotobuf -labsl_graphcycles_internal -labsl_random_internal_platform -labsl_status -labsl_hashtablez_sampler -labsl_periodic_sampler -labsl_random_seed_sequences -labsl_time -labsl_symbolize -labsl_raw_hash_set -labsl_time_zone -labsl_strerror -labsl_cordz_functions -labsl_flags_reflection -labsl_civil_time -labsl_random_internal_seed_material -labsl_flags_private_handle_accessor -labsl_strings -labsl_random_internal_randen -labsl_failure_signal_handler -labsl_city -labsl_synchronization -labsl_random_internal_randen_hwaes -labsl_log_severity -labsl_demangle_internal -labsl_cordz_sample_token -labsl_random_distributions -labsl_int128 -labsl_random_seed_gen_exception -labsl_hash -labsl_cord_internal -labsl_raw_logging_internal -labsl_leak_check -labsl_debugging_internal -labsl_random_internal_pool_urbg -labsl_flags_internal -labsl_flags_config -labsl_statusor -labsl_random_internal_randen_slow -lprotoc -labsl_cordz_handle -labsl_random_internal_distribution_test_util

有任何问题可留言,或向我付费咨询以便快速解决您的问题。

你可能感兴趣的:(Linux开发,linux,grpc)