當前位置:編程學習大全網 - 腳本源碼 - 如何在線安裝pcre

如何在線安裝pcre

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就行

  • 上一篇:亞馬遜買書幾天到
  • 下一篇:屋塔房王世子這個劇沒看懂,好象是誰替誰死了
  • copyright 2024編程學習大全網