CentOS 7.3编译Rsyslog 8.1903.0

源码下载:

1
2
# wget https://github.com/rsyslog/rsyslog/archive/v8.1903.0.tar.gz
# tar xzvf v8.1903.0.tar.gz

创建构建环境:

1
# autoreconf -fvi

创建过程中出现以下错误:

1
2
3
4
5
6
configure.ac:46: error: possibly undefined macro: AC_DISABLE_STATIC
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:49: error: possibly undefined macro: AC_LIBTOOL_DLOPEN
configure.ac:52: error: possibly undefined macro: AC_PROG_LIBTOOL
autoreconf: /usr/bin/autoconf failed with exit status: 1

原因是缺少libtool,执行以下命令安装:

1
# yum install libtool

执行配置,可以自定义选项,我是因为要编译omhttp模块,所以使用以下命令:

1
# ./configure --enable-omhttp

执行过程汇总出现以下错误:

1
2
3
4
checking for LIBESTR... no
configure: error: Package requirements (libestr >= 0.1.9) were not met:

No package 'libestr' found

使用以下命令检查:

1
2
# rpm -q libestr
libestr-0.1.9-2.el7.x86_64

安装开发包后解决:

1
# yum install libestr-devel

再次执行配置出现以下错误:

1
2
3
4
checking for LIBFASTJSON... no
configure: error: Package requirements (libfastjson >= 0.99.8) were not met:

No package 'libfastjson' found

检查系统安装的包:

1
2
# rpm -q libfastjson
libfastjson-0.99.4-3.el7.x86_64

安装新版本。源码下载:http://download.rsyslog.com/libfastjson/。下载libfastjson-0.99.8.tar.gz

1
2
3
4
5
6
# wget http://download.rsyslog.com/libfastjson/libfastjson-0.99.8.tar.gz
# tar xzvf libfastjson-0.99.8.tar.gz
# cd libfastjson-0.99.8/
# ./configure --prefix=/usr CC="gcc -m64" PKG_CONFIG_PATH="/usr/lib64/pkgconfig" --libdir=/usr/lib64
# make
# make install

再次执行配置出现以下错误:

1
2
3
4
checking for LIBUUID... no
configure: error: Package requirements (uuid) were not met:

No package 'uuid' found

安装libuuid:

1
# yum install libuuid libuuid-devel

再次执行配置出现以下错误:

1
2
configure: error: in `/data/rsyslog/rsyslog-8.1903.0':
configure: error: libgcrypt-config not found in PATH

安装libgcrypt模块:

1
# yum install libgcrypt libgcrypt-devel

再次执行配置成功。^_^

执行编译:

1
# make

编译过程出现以下错误:

1
2
3
4
5
6
7
8
make[2]: 进入目录“/data/rsyslog/rsyslog-8.1903.0/grammar”
YACC grammar.c
../ylwrap:行178: yacc: 未找到命令
make[2]: *** [grammar.c] 错误 127
make[2]: 离开目录“/data/rsyslog/rsyslog-8.1903.0/grammar”
make[1]: *** [all-recursive] 错误 1
make[1]: 离开目录“/data/rsyslog/rsyslog-8.1903.0”
make: *** [all] 错误 2

安装byacc:

1
# yum install byacc

再次编译出现以下错误:

1
2
3
4
5
6
7
make  all-am
make[3]: 进入目录“/data/rsyslog/rsyslog-8.1903.0/grammar”
CC libgrammar_la-grammar.lo
LEX lexer.c
CC libgrammar_la-lexer.lo
gcc: error: ./lexer.c: No such file or directory
gcc: fatal error: no input files

这是因为在make前需要执行:

1
# sh autogen.sh

编译omhttp模块:

1
2
3
4
# contrib/omhttp
# make
CC omhttp_la-omhttp.lo
CCLD omhttp.la

执行完成后再次make,生成的omhttp.so文件在contrib/omhttp/.libs目录下。

至此,大功告成!!O(∩_∩)O哈哈~