交叉编译gRPC

1. install zlib with /home/ibm/arm-linux-gnueabihf/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc --sysroot=/home/ibm/arm-linux-gnueabihf/sysroot-glibc-arm-linux

$./configure --prefix=/home/ibm/arm-linux-gnueabihf/sysroot-glibc-arm-linux/usr --includedir=/home/ibm/arm-linux-gnueabihf/sysroot-glibc-arm-linux/usr/include --libdir=/home/ibm/arm-linux-gnueabihf/sysroot-glibc-arm-linux/lib/
$make 
$make install

2. intall openssl-1.1.1b

./Configure --prefix=/home/ibm/arm-linux-gnueabihf/sysroot-glibc-arm-linux/usr --openssldir=/home/ibm/arm-linux-gnueabihf/sysroot-glibc-arm-linux/usr/ssl --libdir=/home/ibm/arm-linux-gnueabihf/sysroot-glibc-arm-linux/lib/  linux-armv4
$make 
$make install

3. cross compiling grpc
GRPC_CROSS_COMPILE=true
PROTOBUF_CONFIG_OPTS=--host=arm-linux --with-protoc=/usr/local/bin/protoc
HAS_PKG_CONFIG=false
#
# The steps for cross-compiling are as follows:
# First, clone and make install of grpc using the native compilers for the host.
# Also, install protoc (e.g., from a package like apt-get)
# Then clone a fresh grpc for the actual cross-compiled build
# Set the environment variable GRPC_CROSS_COMPILE to true
# Set CC, CXX, LD, LDXX, AR, and STRIP to the cross-compiling binaries
# Also set PROTOBUF_CONFIG_OPTS to indicate cross-compilation to protobuf (e.g.,
#  PROTOBUF_CONFIG_OPTS="--host=arm-linux --with-protoc=/usr/local/bin/protoc" )
# Set HAS_PKG_CONFIG=false
# To build tests, go to third_party/gflags and follow its ccmake instructions
# Make sure that you enable building shared libraries and set your prefix to
# something useful like /usr/local/cross
# You will also need to set GRPC_CROSS_LDOPTS and GRPC_CROSS_AROPTS to hold
# additional required arguments for LD and AR (examples below)
# Then you can do a make from the cross-compiling fresh clone!
$make

$cp /home/ibm/arm-linux-gnueabihf/grpc/libs/opt/* /home/ibm/arm-linux-gnueabihf/sysroot-glibc-arm-linux/usr/lib/

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

修改grpc Makefile:

1、修改default 编译工具

DEFAULT_CC=/home/abc/arm-linux-gnueabihf/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
DEFAULT_CXX=/home/abc/arm-linux-gnueabihf/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++

2、设置protobuf 交叉编译变量:

GRPC_CROSS_COMPILE=true
PROTOBUF_CONFIG_OPTS=--host=arm-linux --with-protoc=/usr/local/bin/protoc
HAS_PKG_CONFIG=false

#
# The steps for cross-compiling are as follows:
# First, clone and make install of grpc using the native compilers for the host.
# Also, install protoc (e.g., from a package like apt-get)
# Then clone a fresh grpc for the actual cross-compiled build
# Set the environment variable GRPC_CROSS_COMPILE to true
# Set CC, CXX, LD, LDXX, AR, and STRIP to the cross-compiling binaries
# Also set PROTOBUF_CONFIG_OPTS to indicate cross-compilation to protobuf (e.g.,
#  PROTOBUF_CONFIG_OPTS="--host=arm-linux --with-protoc=/usr/local/bin/protoc" )
# Set HAS_PKG_CONFIG=false
# To build tests, go to third_party/gflags and follow its ccmake instructions
# Make sure that you enable building shared libraries and set your prefix to
# something useful like /usr/local/cross
# You will also need to set GRPC_CROSS_LDOPTS and GRPC_CROSS_AROPTS to hold
# additional required arguments for LD and AR (examples below)
# Then you can do a make from the cross-compiling fresh clone!
#

 

3、执行make 时,设置host 端编译工具:

# The HOST compiler settings are used to compile the protoc plugins.
# In most cases, you won't have to change anything, but if you are
# cross-compiling, you can override these variables from GNU make's
# command line: make CC=cross-gcc HOST_CC=gcc

HOST_CC ?= $(CC)
HOST_CXX ?= $(CXX)
HOST_LD ?= $(LD)
HOST_LDXX ?= $(LDXX)

$make HOST_CXX=gcc  HOST_LD=/usr/bin/ld   HOST_LDXX=/usr/bin/ld
 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值