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: *** [libphp5.5.5.la] 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!

  • use the command file to find out if /usr/libpcre.a is 32bit or 64bit please Dec 19, 2013 at 18:29

1 Answer 1


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. libpcre.so) 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.

  • Perfect. This solved it.
    – s1lv3r
    Dec 19, 2013 at 22:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .