Chinaunix首页 | 论坛 | 博客
  • 博客访问: 117713
  • 博文数量: 54
  • 博客积分: 2986
  • 博客等级: 少校
  • 技术积分: 600
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-18 10:26
文章分类

全部博文(54)

文章存档

2012年(2)

2011年(16)

2010年(36)

我的朋友

分类: LINUX

2011-10-09 18:03:34

PCRE的安装及使用
  1、主页地址:www pcre org
  下载pcre-8.13 tar bz2
  2、解压缩:
  tar xjpf pcre-8.13 tar bz2
  3、配置:
  cd pcre-8.13  
./configure --prefix=/usr/local/pcre-8.13 --libdir=/usr/local/lib/pcre --includedir=/usr/local/include/pcre
  configure有许多参数可配,具体参见./configure --help及手册
  4、编译:
  make
  5、安装:
  make install
  6、将库文件导入cache:
  方法1:在/etc/ld.so.conf中加入: /usr/local/lib/pcre,然后运行ldconfig
  方法2:在/etc/ld.so.conf.d/下新生成一个文件(或在其中的文件中加入同样内容),文件内容为:
  /usr/local/lib/pcre,然后运行ldconfig
    7、编译自带的demo程序
gcc -Wall pcredemo.c -I/usr/local/include/pcre -L/usr/local/lib/pcre -lpcre -o pcredemo
    8、执行
./pcredemo -g 'cat|dog' 'the dog sat on the cat'
./pcredemo 'cat|dog' 'the cat sat on the mat'
 
    安装过程遇到的问题,在ubuntu 10.04下,如果直接./configure;make;make intall的话,默认安装的目录是/usr/local/,但是,即使用
gcc -Wall pcredemo.c -I/usr/local/include -L/usr/local/lib -lpcre -o pcredemo
编译,执行时会出现./pcredemo: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory
    错误的原因是没用用ldconfig加载库文件到cache。只需按第6步将库文件加载到cache就行

 
 
阅读(696) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~