Ok, this is the problem:

if we need higher version of library in , how should we get it if it’s not in any repository?

So, after a long time study, I found the only way is to compile it by myself. Actually, it’s not a big problem. But the thing is libpcre is a widely used package in CentOS. By running remove libpcre, you will realize that. So we couldn’t use yum to help us do that. What can we do?

*   Step 0: ALL YOU LIBPCRE LIBRARIES INSTALLED. This is an very important step but I found most tutorial online didn’t mention that, which will results a disaster if you don’t do that. The way I do it is very simple.
1.  Run -ql pcre which will give you the location of the libraries
2.  Copy these files to a location, like what I did cp /usr/lib64/libpcre.so.1 // actually this is the only lib needed
*   Step 1: remove installed libpcre
1.  Run rpm -qa | grep -i pcr and get the packages installed related to pcre
2.  Run rpm -e --nodeps "XXX " to remove installed pcre, replace XXX by the name of pcre library, for my case, I have pcre-8.32-15.el7_2.1.x86_64
*   Step 2: Ok, you will find you couldn’t use any now! It’s time to create a symbolic link for the previous lib we backed up. Just run ln -sf /root/libpcre.so.1 /usr/lib64/libpcre.so.1. Note that, you should replace the first argument by the location of the file you backed up and the second by the location where it should be at.
*   Step 3: and compile libpcre
1.  Download the version you want and untar it. I use 8.41 version Download link
2.  Configure it.
./configure    --libdir=/usr/lib64      &
--docdir=/usr//doc/pcre-8.41    &
--enable-unicode-properties          &
--enable-pcre16                      &
--enable-pcre32                      &
--enable-pcregrep-libz               &
--enable-pcregrep-libbz2             &
--enable-pcretest-libreadline        &
---static                     &
--enable-utf8                        &
--enable-unicode-properties

One thing you should keep in mind is that the libdir should be the location where you want the library to be installed. Usually, it should be the same as the directory where the previous library is in. For my CentOS7, the location is /usr/lib64. I guess for 32bit system it might be /usr/lib?
3. Time to make! Just type make first. Once it’s made, type make to install that.
4. Check if you have a bunch of libpcre* in /usr/lib64, and use readlink /usr/lib64/libpcre.so.1 to double check if it’s correctlly linked to the new compiled file, and ldd /usr/bin/grep to check if the library works correctly

  • Step 5: If everthing goes well now, you are DONE!

There isn’t step 4 because I hate number four.

 

Print Friendly, PDF & Email

Comments

comments

Bài viết liên quan