最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c - MAKEing PHP ld: error: relocation R_X86_64_32 cannot be used against local symbol - Stack Overflow

programmeradmin4浏览0评论

I'm trying to build PHP 8.4 from source with GD/zlib enabled on Unix

root@dev:/ # uname -a
FreeBSD dev 14.2-RELEASE FreeBSD 14.2-RELEASE releng/14.2-n269506-c8918d6c7412 GENERIC amd64

When I run make I get (just showing the first few lines)

ld: error: relocation R_X86_64_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in /usr/local/lib/libz.a(gzwrite.o)
>>> referenced by gzwrite.c
>>>               gzwrite.o:(gzwrite) in archive /usr/local/lib/libz.a

ld: error: relocation R_X86_64_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in /usr/local/lib/libz.a(gzread.o)
>>> referenced by gzread.c
>>>               gzread.o:(gzread) in archive /usr/local/lib/libz.a

ld: error: relocation R_X86_64_32S cannot be used against local symbol; recompile with -fPIC
>>> defined in /usr/local/lib/libz.a(gzlib.o)
>>> referenced by gzlib.c
>>>               gzlib.o:(gz_open) in archive /usr/local/lib/libz.a

My configure command (PKG_CONFIG_PATH set to overcome a libjpeg error):

setenv PKG_CONFIG_PATH /usr/local/lib/pkgconfig
./configure \
--with-apxs2=/usr/local/apache/bin/apxs \
--without-pdo-sqlite --without-sqlite3 --without-iconv \
--with-config-file-path=/usr/local/etc \
--enable-bcmath --without-cdb \
--enable-gd --without-iodbc  \
--without-gdbm --with-ndbm --without-db2 --without-dbm \
--without-readline --with-openssl \
--without-db3 --enable-dba \
--with-curl \
--with-jpeg --enable-calendar \
--with-mhash --enable-mbstring=all \
--with-zlib \
--enable-exif --with-zip \
--with-mysqli=mysqlnd

I tried setenv ZLIB_CFLAGS -fPIC before running configure and make

I tried to rebuild zlib

root@dev:/usr/local/zlib-1.3.1 # make -fPIC
make: cannot open PIC.

I also installed zlib from pkg install lzlib-1.14_1 - still getting the error

On csh

I'm trying to build PHP 8.4 from source with GD/zlib enabled on Unix

root@dev:/ # uname -a
FreeBSD dev 14.2-RELEASE FreeBSD 14.2-RELEASE releng/14.2-n269506-c8918d6c7412 GENERIC amd64

When I run make I get (just showing the first few lines)

ld: error: relocation R_X86_64_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in /usr/local/lib/libz.a(gzwrite.o)
>>> referenced by gzwrite.c
>>>               gzwrite.o:(gzwrite) in archive /usr/local/lib/libz.a

ld: error: relocation R_X86_64_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in /usr/local/lib/libz.a(gzread.o)
>>> referenced by gzread.c
>>>               gzread.o:(gzread) in archive /usr/local/lib/libz.a

ld: error: relocation R_X86_64_32S cannot be used against local symbol; recompile with -fPIC
>>> defined in /usr/local/lib/libz.a(gzlib.o)
>>> referenced by gzlib.c
>>>               gzlib.o:(gz_open) in archive /usr/local/lib/libz.a

My configure command (PKG_CONFIG_PATH set to overcome a libjpeg error):

setenv PKG_CONFIG_PATH /usr/local/lib/pkgconfig
./configure \
--with-apxs2=/usr/local/apache/bin/apxs \
--without-pdo-sqlite --without-sqlite3 --without-iconv \
--with-config-file-path=/usr/local/etc \
--enable-bcmath --without-cdb \
--enable-gd --without-iodbc  \
--without-gdbm --with-ndbm --without-db2 --without-dbm \
--without-readline --with-openssl \
--without-db3 --enable-dba \
--with-curl \
--with-jpeg --enable-calendar \
--with-mhash --enable-mbstring=all \
--with-zlib \
--enable-exif --with-zip \
--with-mysqli=mysqlnd

I tried setenv ZLIB_CFLAGS -fPIC before running configure and make

I tried to rebuild zlib

root@dev:/usr/local/zlib-1.3.1 # make -fPIC
make: cannot open PIC.

I also installed zlib from pkg install lzlib-1.14_1 - still getting the error

On csh

Share Improve this question asked yesterday KevInSolKevInSol 2,6424 gold badges34 silver badges46 bronze badges 4
  • Is there a reason why you are trying to link against a static libz to begin with? – Mike Kinghan Commented yesterday
  • @MikeKinghan It's not me that's wanting to do that, it's the makefile generated by the PHP configure. – KevInSol Commented yesterday
  • Do you mean that this Makefile also built zlib and installed the static version in /usr/local/lib where the linker is looking for it? Is there also a shared version libz.so in the same place? – Mike Kinghan Commented yesterday
  • I might have it fixed, will post solution when I'm sure. – KevInSol Commented yesterday
Add a comment  | 

1 Answer 1

Reset to default 0

Thanks to the comments from @Mike Kinghan, I turned my attention to the zlib installation, which I had done last week (or maybe week before) as a dependency for GD/PHP.

I had previously installed zlib-1.3.1 from source and, I thought from the package, but looking at the contents of /usr/local/lib it seems I installed a zip library from the package by mistake.

Doing:

root@dev: # pkg search zlib
linux-c7-zlib-devel-1.2.7      Zlib headers (Linux CentOS 7.9.2009)
lua51-lzlib-0.4.3_1            Lua bindings to the ZLib compression library
lua51-zlib-1.2_1               Simple streaming interface to zlib for the Lua Programming Language
lua52-lzlib-0.4.3_1            Lua bindings to the ZLib compression library
lzlib-1.14_1                   In-memory LZMA compression and decompression library
p5-Compress-Raw-Zlib-2.213     Low-Level Interface to zlib compression library
p5-IO-Zlib-1.15                IO:: style interface to Compress::Zlib
p5-POE-Filter-Zlib-2.04        POE filter wrapped around Compress::Zlib
php81-zlib-8.1.31              The zlib shared extension for php
php82-zlib-8.2.27              The zlib shared extension for php
php83-zlib-8.3.15              The zlib shared extension for php
php84-zlib-8.4.2               The zlib shared extension for php
py311-zlib-ng-0.5.1            Python bindings for the zlib-ng library
rubygem-zlib-3.2.1             Ruby interface for the zlib compression/decompression library
zlib-ng-2.2.4                  Fork of the zlib data compression library

I saw the php84-zlib-8.4.2 so installed that and it worked!

I now have these files (which was pretty much what I had before) but with the addition of libz.a which is the only one dated this week, and this was the first one it failed on, so assume this was what fixed it.

root@dev: # dir /usr/local/lib/*z*
lrwxr-xr-x  1 root wheel      24 Feb  7 19:42 /usr/local/lib/libharfbuzz-gobject.so -> libharfbuzz-gobject.so.0
lrwxr-xr-x  1 root wheel      32 Feb  7 19:42 /usr/local/lib/libharfbuzz-gobject.so.0 -> libharfbuzz-gobject.so.0.61001.0
-rwxr-xr-x  1 root wheel  118864 Feb  7 19:42 /usr/local/lib/libharfbuzz-gobject.so.0.61001.0
lrwxr-xr-x  1 root wheel      23 Feb  7 19:42 /usr/local/lib/libharfbuzz-subset.so -> libharfbuzz-subset.so.0
lrwxr-xr-x  1 root wheel      31 Feb  7 19:42 /usr/local/lib/libharfbuzz-subset.so.0 -> libharfbuzz-subset.so.0.61001.0
-rwxr-xr-x  1 root wheel 1281168 Feb  7 19:42 /usr/local/lib/libharfbuzz-subset.so.0.61001.0
lrwxr-xr-x  1 root wheel      16 Feb  7 19:42 /usr/local/lib/libharfbuzz.so -> libharfbuzz.so.0
lrwxr-xr-x  1 root wheel      24 Feb  7 19:42 /usr/local/lib/libharfbuzz.so.0 -> libharfbuzz.so.0.61001.0
-rwxr-xr-x  1 root wheel 1185872 Feb  7 19:42 /usr/local/lib/libharfbuzz.so.0.61001.0
-rw-r--r--  1 root wheel   78048 Jan 30 01:55 /usr/local/lib/liblz.a
lrwxr-xr-x  1 root wheel      13 Jan 30 01:55 /usr/local/lib/liblz.so -> liblz.so.1.14
lrwxr-xr-x  1 root wheel      13 Jan 30 01:55 /usr/local/lib/liblz.so.1 -> liblz.so.1.14
-rwxr-xr-x  1 root wheel   70496 Jan 30 01:55 /usr/local/lib/liblz.so.1.14
-rw-r--r--  1 root wheel  198144 Jan 30 01:18 /usr/local/lib/liblz4.a
lrwxr-xr-x  1 root wheel      11 Jan 30 01:18 /usr/local/lib/liblz4.so -> liblz4.so.1
lrwxr-xr-x  1 root wheel      16 Jan 30 01:18 /usr/local/lib/liblz4.so.1 -> liblz4.so.1.10.0
-rwxr-xr-x  1 root wheel  173192 Jan 30 01:18 /usr/local/lib/liblz4.so.1.10.0
-rw-r--r--  1 root wheel  179444 Feb 19 12:10 /usr/local/lib/libz.a
lrwxr-xr-x  1 root wheel      11 Jan 30 02:15 /usr/local/lib/libzip.so -> libzip.so.5
lrwxr-xr-x  1 root wheel      13 Jan 30 02:15 /usr/local/lib/libzip.so.5 -> libzip.so.5.5
-rwxr-xr-x  1 root wheel  127176 Jan 30 02:15 /usr/local/lib/libzip.so.5.5
-rw-r--r--  1 root wheel 1010218 Jan 30 01:20 /usr/local/lib/libzstd.a
lrwxr-xr-x  1 root wheel      16 Jan 30 01:20 /usr/local/lib/libzstd.so -> libzstd.so.1.5.6
lrwxr-xr-x  1 root wheel      16 Jan 30 01:20 /usr/local/lib/libzstd.so.1 -> libzstd.so.1.5.6
-r-xr-xr-x  1 root wheel  794952 Jan 30 01:20 /usr/local/lib/libzstd.so.1.5.6
  
发布评论

评论列表(0)

  1. 暂无评论