sersync2编译

发布时间 2023-09-12 10:47:07作者: 狄成

1、下载boost编译安装

$ cd path/to/boost_1_64_0
$ ./bootstrap.sh --help
## 配置选项, 相当于configure
$ ./bootstrap.sh --prefix=/usr/local
## 相当于make
$ ./b2
## 相当于make install
$ ./b2 install

完成后boost库将出现在/usr/local/lib目录下

到sersync2源码下直接执行命令make

将在build/Release目录下生成.o等中间文件, 并且dist目录下生成sersync2可执行文件

 

make报错

boost库安装完成后再执行make, 出现

```
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
make[2]: *** [dist/Release/GNU-Linux-x86/sersync2] Error 1
make[2]: Leaving directory `/mnt/hgfs/home/Coding/sersync'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/mnt/hgfs/home/Coding/sersync'
make: *** [.build-impl] Error 2

经过查找, makefile实际生效的是`nbproject/Makefile-Release.mk`, 其中`LDLIBSOPTIONS`选项是编译操作的关键字段

去掉`-static`参数, 添加`libpthread.so`的位置`-L/lib64`

vi nbproject/Makefile-Release.mk

LDLIBSOPTIONS=-Llib -L/lib64 -L/usr/lib64 -L/usr/local/lib -lboost_thread -lboost_regex -lboost_system -lboost_date_time -lpthread -lrt -static-libgcc

出现问题看readme-detail.md文件有解决方法