compiling PHP fails cause of libpcre

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years 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: *** [libphp5.5.5.la] Fehler 1
Error

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!

profilepic.png
manpreet 2 years 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. 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.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.