当前位置:网站首页>phxpaxos安装编译流程
phxpaxos安装编译流程
2022-07-23 05:40:00 【冲鸭hhh】
phxpaxos安装编译流程
一、前言
这篇博客记录了腾讯微信团队的phxpaxos安装编译过程,记录一些编译过程中的坑。
github链接:
phxpaxos github链接
官方文档的编译手册:
编译手册
然而,官方的编译手册年代久远,所以依照其流程来操作可能会遇到一些问题,这里总结一下自己安装过程中的坑,并使用不同于编译手册的方式进行编译安装。
二、安装过程
1. 拉取代码
官方文档使用
git clone --recursive https://github.com/tencent-wechat/phxpaxos.git
来拉取代码,这样可以把submodule一起拉取,但由于连接缓冲区大小或者连接超时时间的原因,有可能没办法一次拉取下来,所以可以尝试:先
git clone https://github.com/tencent-wechat/phxpaxos.git
拉取不带submodule的代码,然后进入./phxpaxos目录下,
git submodule init
git submodule update
拉取submodule,如果一次update不成功(连接失败或者只拉取了部分submodule),可以多用几次git submodule update直到所有submodule更新完成。
2. 编译 submodules(依赖库)
直接运行
../phxpaxos/third_party/autoinstall.sh
为什么不按照官方编译手册来
phxpaxos依赖leveldb、protobuf等module,这部分代码在../phxpaxos/third_party中,目录如下:
官方手册分别编译不同的模块,这样比较麻烦,而且不够灵活,所以我们使用../phxpaxos/third_party/autoinstall.sh来进行安装编译。为什么不推荐跟着手册来,举两个例子:
1.在安装leveldb的时候官方手册有如下操作:
mkdir lib建立一个lib目录,然后
cd lib;ln -s ../libleveldb.a libleveldb.a建立一个软链,PhxPaxos通过lib这个目录来寻址静态库。
但实际上libleveldb.a可能并不在third_party/leveldb目录下,而是在third_party/leveldb/out-static目录下,而在../phxpaxos/third_party/autoinstall.sh中会自行判断并链接
2.在安装protobuf的时候官方手册有如下操作:
进入
third_party/protobuf目录,运行./autogen.sh
protobuf依赖gmock,所以在./autogen.sh中会下载安装gmock,但图示链接被墙,搭梯子上去之后也是404.
而在../phxpaxos/third_party/autoinstall.sh中会先尝试重用third_party目录中的gmock(gmock也是phxpaxos的submodule),然后再运行protobuf的./autogen.sh,所以并不会出现问题。
可能会遇到的坑
a. glog aclocal-1.14 不存在

先查看当前版本
版本若不是1.14的话依次进行以下操作:
找个合适的目录,如/usr/local/,然后
autoconf 编译
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar xvzf autoconf-2.69.tar.gz
cd autoconf-2.69; ./configure
make && make install
cd ..
automake 编译
wget http://ftp.gnu.org/gnu/automake/automake-1.14.tar.gz
tar xvzf automake-1.14.tar.gz; cd automake-1.14
./configure
make && make install
重新运行../phxpaxos/third_party/autoinstall.sh即可。
b. glog ‘./test-driver’ not found

修改../phxpaxos/third_party/autoinstall.sh脚本
在install_glog()函数中画框的位置添加:
automake --add-missing
aclocal-1.14
重新运行../phxpaxos/third_party/autoinstall.sh便可下载缺失文件并正常工作。
c. protobuf 找不到AC_PROG_LIBTOOL

由于安装了多个版本的aclocal(重新安了1.14),导致aclocal扫描configure.ac中所有的宏定义并展开的时候路径错误。aclocal是去默认安装目录/usr/share/aclocal下面搜索所有的.m4文件找所定义的宏,但是由于安装了多个aclocal,可能aclocal目录不存在,实际目录为/usr/local/share/aclocal等,这就造成了aclocal找不到m4文件的情况,需要将复制一份.m4文件到/usr/local/share/aclocal,因此需要执行以下命令
cp /usr/share/aclocal/*.m4 /usr/local/share/aclocal/
重新运行../phxpaxos/third_party/autoinstall.sh便可正常执行。
3. 编译PhxPaxos静态库
回到phxpaxos根目录
cd phxpaxos/
./autoinstall.sh
make && make install //默认使用-O2编译优化参数,如需编译debug版本,则命令为make debug=y
如仅需使用libphxpaxos.a进行开发,则编译就到此完成了。而如果希望使用我们的glog打日志插件模块,或者想尝试编译sample目录,或用于phxsql使用,则还需要编译libphxpaxos_plugin.a, 这个静态库依赖了glog。
4. 编译PhxPaxos Plugin静态库
cd phxpaxos/plugin
make && make install
编译成功检查上层lib目录下是否成功生成静态库libphxpaxos_plugin.a
三、example-phxecho
编译phxecho
cd ../phxpaxos/sample/phxecho
make
mkdir log
运行测试
// 启动三个进程
./phxecho 127.0.0.1:1000 127.0.0.1:1000,127.0.0.1:1001,127.0.0.1:1002
./phxecho 127.0.0.1:1001 127.0.0.1:1000,127.0.0.1:1001,127.0.0.1:1002
./phxecho 127.0.0.1:1002 127.0.0.1:1000,127.0.0.1:1001,127.0.0.1:1002



输入的内容会被所有进程看到并记录。
边栏推荐
- 第一篇博客
- 数字藏品开发/数字藏品系统开发解决方案
- MySQL之函数&视图&导入导出
- Php+ code cloud code hook automatically updates online code
- Sequencing, current limiting
- $attrs中的对象没有变化,但触发了watch监听?
- 再见if-else
- Py program can run, but the packaged exe prompts an error: recursion is detected when loading the "CV2" binary extension. Please check the opencv installation.
- NFT数字藏品开发:数字藏品在未来究竟有哪些可能的应用场景?
- Goodbye if else
猜你喜欢

MySQL之账号管理&&四大引擎&&建库建表
![[C language] what is a function? Classification and emphasis of functions (help you quickly classify and remember functions)](/img/3b/39be991aa30b31ff5fb49905de36cf.jpg)
[C language] what is a function? Classification and emphasis of functions (help you quickly classify and remember functions)

Custom MVC (Part 1)

MySQL之函数&视图&导入导出

Dynamically set the theme color of the card

BurpSuite学习笔记

第六届“蓝帽杯”全国大学生网络安全技能大赛-初赛Writeup

laravel api接口+令牌认证登录

Simple implementation of rectangular area block

用getchar清理缓冲区(强烈推荐,C语言易错典型)
随机推荐
pycharm如何正确打包ocr且让打包出来的exe尽量小
页面实现 “实时数据响应” 的注意事项
存储过程 两次排序加一次随机取数据
数字藏品开发/数字藏品系统开发解决方案
Basis of penetration test
uni-app小程序中v-show与display:flex一起使用时v-show不生效!
自定义forEach标签&&select标签实现回显数据
Application of higher-order functions: handwritten promise source code (I)
php+码云 代码钩子自动更新线上代码
Nepctf 2022 misc < check in question > (extreme doll)
Vite X Figma 打造设计师专属的 i18n 插件
PHP文件上传中fileinfo出现的安全问题
Clear the buffer with getchar (strongly recommended, C language is error prone, typical)
When v-show is used with display:flex in the uni app applet, v-show does not take effect!
NPM init vite app < project name > error install for[‘ [email protected] ‘] failed with code 1
Constructor, prototype chain, instanceof
mysql和sql server的设置优化及使用
First meet flask
my_ Implementation of strcpy (classic, simple, practical, collection)
General view, serializer