PHP静态编译开启curl扩展总是失败

编译参数

仅测试curl静态编译,所以编译参数如下:

./configure LDFLAGS="-static -static-libgcc" \
--prefix=/usr/local/php/php7.4.4/ \
--with-config-file-path=/usr/local/php/php7.4.4/ \
--with-libdir=lib/x86_64-linux-gnu \
--disable-all \
--with-curl

或者手动指定 curl 路径

./configure LDFLAGS="-static -static-libgcc" \
--prefix=/usr/local/php/php7.4.4/ \
--with-config-file-path=/usr/local/php/php7.4.4/ \
--with-libdir=lib/x86_64-linux-gnu \
--disable-all \
--with-curl=/usr/local/curl

报错内容

在 configure 阶段就产生的错误:

gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)
configure:4454: $? = 0
configure:4443: cc -V >&5
cc: error: unrecognized command line option '-V'
cc: fatal error: no input files
compilation terminated.
configure:4454: $? = 1
configure:4443: cc -qversion >&5
cc: error: unrecognized command line option '-qversion'; did you mean '--version'?
cc: fatal error: no input files
...

configure:4970: cc -E  conftest.c
conftest.c:9:10: fatal error: ac_nonexistent.h: No such file or directory
 #include <ac_nonexistent.h>
          ^~~~~~~~~~~~~~~~~~
compilation terminated
...

configure:5373: checking minix/config.h usability
configure:5373: cc -c -g -O2  conftest.c >&5
conftest.c:52:10: fatal error: minix/config.h: No such file or directory
 #include <minix/config.h>
          ^~~~~~~~~~~~~~~~
compilation terminated
...

configure:6393: checking for pthreads_cflags
configure:6423: cc -o conftest -g -O2 -fvisibility=hidden -kthread  -static -static-libgcc conftest.c  >&5
cc: error: unrecognized command line option '-kthread'; did you mean '-pthread'?
configure:6423: $? = 1
configure: failed program was:
...

configure:7260: cc -o conftest -g -O2 -fvisibility=hidden  -static -static-libgcc conftest.c  >&5
/tmp/ccKajTU1.o: In function `main':
/mnt/tools/php-7.4.4/conftest.c:62: undefined reference to `setproctitle'
collect2: error: ld returned 1 exit status

系统环境

Debian9、CentOS8 均能复现出问题

安装过 libcurl-devel

yum install -y libcurl-devel

automake、autoconf、libtool、gcc 版本:

# rpm -qf /usr/bin/autoconf
autoconf-2.69-27.el8.noarch

# automake --version
automake (GNU automake) 1.16.1

# libtool --version
libtool (GNU libtool) 2.4.6

# gcc -v
gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)

麻烦各位给予解答或者帮助,感谢!

阅读 371
评论
    2 个回答
    • 13.6k

    yum install gcc gcc-c++ -y

      相似问题
      推荐文章