php-src icon indicating copy to clipboard operation
php-src copied to clipboard

`php-config --libs` should also respond with the `-lphp` so apps know which library to link

Open gdamjan opened this issue 4 years ago • 1 comments

Description

Debian:

$ php-config --libs
-lcrypt -largon2 -lresolv -lcrypt -lrt -lm -ldl -lxml2 -lssl -lcrypto -lpcre2-8 -lz -lsodium -lcrypt -largon2 -lcrypt
$ php-config8.1 --libs
-lcrypt -lresolv -lcrypt -lutil -lrt -lm -ldl -lxml2 -lssl -lcrypto -lpcre2-8 -lz -lsodium -largon2 -lrt -ldl -lcrypt
$ php-config7.4 --libs
-lcrypt -largon2 -lresolv -lcrypt -lrt -lm -ldl -lxml2 -lssl -lcrypto -lpcre2-8 -lz -lsodium -lcrypt -largon2 -lcrypt

Arch

$ php-config7 --libs
-lcrypt -largon2 -lresolv -lcrypt -lreadline -lncurses -lrt -lstdc++ -lrt -lm -ldl -lacl -lsystemd -lxml2 -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lssl -lcrypto -lpcre2-8 -lz -lxml2 -lonig -lxml2 -lcrypt -largon2 -lxml2 -lxml2 -lxml2 -lz -lssl -lcrypto -lcrypt
$ php-config --libs
-lcrypt -largon2 -lresolv -lcrypt -lreadline -lncurses -lrt -lstdc++ -lutil -lrt -lm -ldl -lacl -lsystemd -lxml2 -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lssl -lcrypto -lpcre2-8 -lz -lxml2 -lonig -lxml2 -largon2 -lxml2 -lxml2 -lxml2 -lz -lssl -lcrypto -lcrypt

An application should guess which libphp to link to. It's /usr/lib/libphp.so for PHP 8 on Arch, /usr/lib/libphp7.so for PHP 7.4. On Debian there are: /usr/lib/libphp7.4.so /usr/lib/libphp7.so /usr/lib/libphp8.1.so /usr/lib/libphp8.so /usr/lib/libphp.so

php-config --libs should actually specify the correct -lphp flag.

gdamjan avatar Dec 29 '21 15:12 gdamjan

It's not ordinary to link to libphp, an artifact only produced when it is a pre-requisite of the SAPI.

If you are using this part of the build system in some extraordinary way, it's assumed that you will know how and if to link to libphp.

While you might not find it written anywhere, it has been this way for so long that it may be problematic for other extraordinary builds to change it now. If you look in the README for the embed SAPI for example, there is mention of the fact that php-config is not expected to add libphp or it's path to --libs or --ldflags.

krakjoe avatar Aug 08 '22 14:08 krakjoe