See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More
( 7 months ago )

compiling PHP fails cause of libpcre

General Tech Bugs & Fixes
Max. 2000 characters

Raman Tripathi


( 7 months ago )

You need to rebuild libpcre with position independent code. The straightforward way to do that is to build or install the libpcre shared objects (e.g. which are built with -fPIC.

Since the library archive was in /usr/lib/x86_64-linux-gnu, the shared objects might be there also. Try adding -L/usr/lib/x86_64-linux-gnu to LDFLAGS of php. This will also save you from symlinking to /usr.

Harsh Vashishth


( 7 months ago )


I'm trying to compile PHP myself as I want to use PHPBrew to switch between multiple versions of PHP.

I already solved a ton of problems in the process, but with this particular one I can't get any further. I'm getting this error message in the make process:

/usr/bin/ld: /usr/libpcre.a(pcre_exec.o): relocation R_X86_64_32S against `_pcre_ucd_stage1' can not be used when making a shared object; recompile with -fPIC
/usr/libpcre.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [] Fehler 1

I needed to add a symlink from /usr/libpcre.a -> /usr/lib/x86_64-linux-gnu/libpcre.a before, as otherwise he would complain about not beeing able to find libpcre.a.

I also tried to add "EXTRACFLAGS=-fPIC" to make, but it wouldn't change anything. It's the first time I'm compiling something, so I'm not even sure if I get the basics right.

This is under Ubuntu 13.10 (not seeing the same problems on 12.04). This is my PHPBrew command:

phpbrew install 5.5.5 +default+mysql+pdo+apxs2

Wich results in the following configure options being generated:

./configure '--prefix=/home/malte/.phpbrew/php/php-5.5.5' '--with-config-file-path=/home/malte/.phpbrew/php/php-5.5.5/etc' '--with-config-file-scan-dir=/home/malte/.phpbrew/php/php-5.5.5/var/db' '--with-pear=/home/malte/.phpbrew/php/php-5.5.5/lib/php' '--disable-all' '--enable-phar' '--enable-session' '--enable-short-tags' '--enable-tokenizer' '--with-pcre-regex' '--with-zlib=/usr' '--with-libdir=lib/i386-linux-gnu' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--enable-pdo' '--with-apxs2=/usr/bin/apxs2' '--enable-dom' '--enable-libxml' '--enable-simplexml' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-xsl' '--with-libxml-dir=/usr' '--enable-bcmath' '--with-bz2=/usr' '--enable-calendar' '--enable-cli' '--enable-ctype' '--enable-dom' '--enable-fileinfo' '--enable-filter' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-json' '--enable-mbregex' '--enable-mbstring' '--with-mhash' '--with-mcrypt=/usr' '--enable-pcntl' '--with-pcre-regex=/usr' '--with-pcre-dir=/usr' '--enable-phar' '--enable-posix' '--with-readline=/usr' '--enable-sockets' '--enable-tokenizer' '--enable-zip' 2>&1 > /home/malte/.phpbrew/build/php-5.5.5/build.log

I think I have all relevant packages installed:

dpkg --get-selections | grep pcre
libpcre++0:amd64                install
libpcre3:amd64                  install
libpcre3:i386                   install
libpcre3-dev:amd64              install
libpcrecpp0:amd64               install

Any help is really appreciated!

what's your interest