Hyperscan 5.1.0 安装

本文档详细介绍了如何在Linux系统上安装Hyperscan库,包括依赖ragel和boost的安装步骤,以及遇到的错误处理方法。首先从官方源下载并编译ragel和boost,然后下载Hyperscan源码并编译为动态库。在安装过程中,可能遇到pkg-config找不到libhs或运行时找不到libhs.so.5的问题,解决办法是更新PKG_CONFIG_PATH环境变量和ld.so.conf文件。通过这些步骤,成功安装并验证了Hyperscan库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

资源包下载:https://download.csdn.net/download/airyearth/16668913

也可以自行去官网下载,注意版本匹配

安装依赖ragel

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

Github地址

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值