phpcurl

PHP 8.2.7 compilation does not work when cURL is included


I get the following installing PHP:

php-8.2.7/ext/curl/interface.c:3085: undefined reference to `curl_easy_upkeep'

I thought this would be a common error (hence the post) and I have tried the following so far:

So if anyone can beat me to it kudos to you.

For reference the full output of the error is:

lcrypto -lcrypt -lrt -o sapi/cli/php
ext/curl/interface.o: In function `zif_curl_upkeep':
/tmp/serverforge/downloads/php-8.2.7/ext/curl/interface.c:3085: undefined reference to `curl_easy_upkeep'
collect2: error: ld returned 1 exit status
make: *** [Makefile:310: sapi/cli/php] Error 1

I tried installing PHP from source (8.2.7) and I expected to have it install with cURL but only works without cURL in the php 8.7.2 configure command.

The full command I used was: ./configure --prefix=/usr/local/php82 --enable-cli --enable-fpm --program-suffix=82 --with-xsl --with-libxml=/usr/local/libxml2 --with-apxs2=/usr/local/apache/bin/apxs --enable-bcmath --with-bz2=/usr/local/bzip2 --enable-calendar --with-curl=/usr/local/curl --enable-ftp --enable-gd --with-libdir=lib64 --with-imap --with-imap-ssl --with-kerberos --enable-intl --enable-mbstring --with-mysqli --with-pdo-mysql --with-openssl=/usr/local/ssl --with-xsl --enable-soap --enable-sockets; make; make install;

Note also, that /usr/local/curl/bin/curl --version outputs 8.8.0.

EDIT I have since discovered that both php74 and php80 compile fine. Can anybody understand what is happening here?

The cURL version is listed below, the libcurl that appears after is installed out of my control, so I do not know where to find it.

[root@localhost]# curl -V curl 8.8.0 (x86_64-pc-linux-gnu) libcurl/8.8.0 OpenSSL/1.1.1k zlib/1.2.11 zstd/1.4.4 OpenLDAP/2.4.46 Release-Date: 2024-05-22 Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: alt-svc AsynchDNS HSTS HTTPS-proxy IPv6 Largefile libz NTLM SSL threadsafe TLS-SRP UnixSockets zstd

I changed the hard links for which curl-config to symlink to /usr/local/curl/bin/curl-config which changed the output but did not change the fact that it doesn't compile.

From looking at my system:

    /usr/local/curl/lib/libcurl.a
    /usr/local/curl/lib/libcurl.la
    /usr/local/curl/lib/libcurl.so
    /usr/local/curl/lib/libcurl.so.4
    /usr/local/curl/lib/libcurl.so.4.7.0
    /usr/local/curl/lib/libcurl.so.4.8.0
    /usr/local/lib/libcurl.a
    /usr/local/lib/libcurl.la
    /usr/local/lib/libcurl.so
    /usr/local/lib/libcurl.so.4
    /usr/local/lib/libcurl.so.4.7.0

There are two installations it seems. How do I make it so the right installation is used? Currently --with-curl=/usr/local/curl is not doing it.

FYI:

[root@localhost]# curl-config --version
libcurl 8.8.0
[root@localhost]# curl-config --help
[root@localhost]# curl-config --static-libs
/usr/local/curl/lib/libcurl.a -lssl -lcrypto -lssl -lcrypto -lldap -llber -lzstd -lz -pthread
[root@localhost bin]# curl-config --ca
"/etc/pki/tls/certs/ca-bundle.crt"
[root@localhost]# curl-config --cc
gcc
[root@localhost]# curl-config --libs
-L/usr/local/curl/lib -lcurl

Solution

  • From your file listing, it seems you have 2x libcurl installations on your system:

    1. /usr/local/curl/lib
    2. /usr/local/lib

    Due to multiple installations, the build process MIGHT still link against older libcurl... So let's have a fresh start:

    1. Rrefresh the library cache: ldconfig
    2. Check which version of libcurl is PHP trying to use: ldd /usr/local/curl/lib/libcurl.so
    3. Clear the build artifacts: make clean
    4. Ensure CORRECT version of libcurl is specified in your LD_LIBRARY_PATH to prioritize this path for linking: export LD_LIBRARY_PATH=/usr/local/curl/lib:$LD_LIBRARY_PATH
    5. You can also add PKG_CONFIG_PATH to make sure pkg-config picks up the correct libcurl.pc: export PKG_CONFIG_PATH=/usr/local/curl/lib/pkgconfig:$PKG_CONFIG_PATH
    6. Reconfigure PHP with your own params: ./configure --prefix=/usr/local/php82...
    7. Build it: make
    8. Verify the CORRECT linked library: ldd sapi/cli/php | grep curl and php -i | grep cURL

    Failed? you can specify linker flags manually in configure command:

    ./configure LDFLAGS="-L/usr/local/curl/lib" CPPFLAGS="-I/usr/local/curl/include" ...