Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brpc安装 #40

Open
guodongxiaren opened this issue Nov 2, 2020 · 0 comments
Open

brpc安装 #40

guodongxiaren opened this issue Nov 2, 2020 · 0 comments
Labels
BRPC 百度RPC

Comments

@guodongxiaren
Copy link
Owner

guodongxiaren commented Nov 2, 2020

github主页:

https://github.com/apache/incubator-brpc

克隆:

git clone https://github.com/apache/incubator-brpc.git

本地依赖

cmake

其中一个gflags需要cmake3,所以要安装cmake3:

yum install cmake3

依赖第三方库

  • gflags
  • leveldb
  • protobuf【2或3均可】
  • openssl

其中gflags、leveldb默认cmake会编译成静态库,编译brpc时会出错:

/usr/local/lib/libgflags.a(gflags.cc.o): relocation R_X86_64_32S against `.rodata' can not be used

需要编译成动态库,编译方法如下:

mkdir bld
cd bld
cmake3 -DBUILD_SHARED_LIBS=ON ..
make -j 8

编译brpc

在确认安装好上述依赖后,cd到brpc的下载目录中。

mkdir bld
cd bld
cmake3 ..
make

编译brpc尽量不要并行make。容易编译失败

编译example

example下面的的代码用cmake编译,可能会失败。最好用普通make编译的方式。

首先要先生成config.mk:

sh config_brpc.sh --headers=/usr/local/include  --libs=/usr/local/lib

headers和libs指定第三方库的头文件和库路径。尽量集中到一起,不在一起的可以建立软连接。

生成config.mk之后,可以去example目录编译。比如:

cd example/echo_c++
make
@guodongxiaren guodongxiaren added C/C++ 兵中凶兽 C++ BRPC 百度RPC and removed C/C++ 兵中凶兽 C++ labels Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BRPC 百度RPC
Projects
None yet
Development

No branches or pull requests

1 participant