资源包下载:https://download.csdn.net/download/airyearth/16668913
也可以自行去官网下载,注意版本匹配
安装依赖ragel
编译安装
$ tar -xvf ragel-6.10.tar.gz
$ cd ragel-6.10
$ ./configure
$ make
$ sudo make install
$ ldconfig
安装依赖boost
boost官网,这里下载的是boost_1_69_0.tar.gz
编译安装,只需要安装iostreams和random就可以了
$ tar -xvf boost_1_69_0.tar.gz
$ cd boost_1_69_0
$ ./bootstrap.sh
$ sudo ./b2 --with-iostreams --with-random install
$ ldconfig
安装hyperscan
在Releases里面选择Hyperscan 5.1.0下载Source code (tar.gz)
编译安装,cmake时指定-DBUILD_SHARED_LIBS=on
编译结果为动态库,不指定默认为静态库
$ tar -xvf hyperscan-5.1.0.tar.gz
$ cd hyperscan-5.1.0
$ mkdir cmake-build
$ cd cmake-build
$ cmake -DBUILD_SHARED_LIBS=on -DCMAKE_BUILD_TYPE=Release ..
$ make -j8
$ sudo make install
$ ldconfig
至此大功告成
root@debian:~# ldconfig -p | grep hs
libhs_runtime.so.5 (libc6,x86-64) => /usr/local/lib/libhs_runtime.so.5
libhs_runtime.so.5 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libhs_runtime.so.5
libhs_runtime.so (libc6,x86-64) => /usr/local/lib/libhs_runtime.so
libhs.so.5 (libc6,x86-64) => /usr/local/lib/libhs.so.5
libhs.so.5 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libhs.so.5
libhs.so (libc6,x86-64) => /usr/local/lib/libhs.so
root@debian:~#
报错处理
- 运行的时候报错
报错(一)
# pkg-config --cflags -- libhs
Package libhs was not found in the pkg-config search path.
Perhaps you should add the directory containing `libhs.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libhs', required by 'virtual:world', not found
pkg-config: exit status 1
解决办法:
1、查找“libhs.pc”文件的路径:
[root@localhost ~]# find / -name libhs.pc
/usr/local/lib64/pkgconfig/libhs.pc
/opt/hyperscan-5.1.0/cmake-build/libhs.pc
2、打开文件:
[root@localhost ~]# vim ~/.bash_profile
3、添加:
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH
4、重启服务器
报错(二)
/tmp/___go_build_main_go: error while loading shared libraries: libhs.so.5: cannot open shared object file: No such file or directory
1、查找文件“libhs.so.5”的位置
[root@localhost Desktop]# find / -name libhs.so.5
/usr/local/lib64/libhs.so.5
/opt/hyperscan-5.1.0/cmake-build/lib/libhs.so.5
2、打开文件
[root@localhost Desktop]# vim /etc/ld.so.conf
3、添加路径
/usr/local/lib64
内容如下:
""""
include ld.so.conf.d/*.conf
/usr/local/lib
/usr/local/lib64
""""
保存退出:wq
4、更新/etc/ld.so.cache文件
[root@localhost Desktop]# sudo ldconfig