Php

編譯PHP失敗導致libpcre

  • December 19, 2013

我正在嘗試自己編譯 PHP,因為我想使用 PHPBrew 在多個 PHP 版本之間切換。

我已經在這個過程中解決了很多問題,但是對於這個特定的問題,我無法再進一步了。我在此make過程中收到此錯誤消息:

/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

我需要從/usr/libpcre.a -> /usr/lib/x86_64-linux-gnu/libpcre.a之前添加一個符號連結,否則他會抱怨找不到libpcre.a.

我也嘗試添加"EXTRACFLAGS=-fPIC"make,但它不會改變任何東西。這是我第一次編譯一些東西,所以我什至不確定我是否掌握了基礎知識。

這是在 Ubuntu 13.10 下(在 12.04 上沒有看到同樣的問題)。這是我的 PHPBrew 命令:

phpbrew install 5.5.5 +default+mysql+pdo+apxs2

這會導致生成以下配置選項:

./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–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–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’–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’–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–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–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–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–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

我想我已經安裝了所有相關的軟體包:

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

非常感謝任何幫助!

您需要libpcre使用與位置無關的程式碼進行重建。直接的方法是建構或libpcre安裝libpcre.so使用-fPIC.

由於庫存檔位於 /usr/lib/x86_64-linux-gnu 中,因此共享對像也可能在那裡。嘗試添加-L/usr/lib/x86_64-linux-gnuLDFLAGSphp.ini 文件中。這也將使您免於符號連結到 /usr。

引用自:https://unix.stackexchange.com/questions/105927