Bug #81032 [PATCH]: GD install is affected by external libgd installation

From: Date: Wed, 12 May 2021 09:39:06 +0000
Subject: Bug #81032 [PATCH]: GD install is affected by external libgd installation
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233803@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81032&edit=1

 ID:                 81032
 Patch added by:     cmb@php.net
 Reported by:        flaviohbatista at gmail dot com
 Summary:            GD install is affected by external libgd
                     installation
 Status:             Assigned
 Type:               Bug
 Package:            GD related
 Operating System:   MacOS
 PHP Version:        Irrelevant
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

The following pull request has been associated:

Patch Name: Fix bundled libgd includes
On GitHub:  https://github.com/php/php-src/pull/6975
Patch:      https://github.com/php/php-src/pull/6975.patch


Previous Comments:
------------------------------------------------------------------------
[2021-05-11 23:51:57] flaviohbatista at gmail dot com

Description:
------------
Description:

When installing the GD extension using the bundled libgd, if any of the libraries used by libgd
(e.g. libjpeg), are installed in a path that also happen to have a libgd installation, the extension
code will include the external libgd files instead of the local ones.

Example:

1. Assume that libjpeg is installed at /usr/local/include;
2. Assume that libgd is also installed at /usr/local/include;
3. The build system will add /usr/local/include to CFLAGS (through pkg-config) for
libjpeg;
3. Once you run make, you may end up in an error referring to
/usr/local/include/gd.h instead of the bundled gd.h.

Root cause:

The bundled libgd fork includes gd.h and other gd-specific header files using
#include <foo.h> rather than #include "foo.h", which
instructs the preprocessor to look for foo.h in the standard system directories and, if
the file wasn't found, fall back to search in additional directories added to the search path.
Reference: https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html

Solution:

Replace #include <foo.h> with #include "foo.h", to ensure
that the lookup will be executed in the local path first and then in the search path as fall back if
the file was not found.

Actual result:
--------------
/Users/flavio/Documents/open-source/php-src/ext/gd/gd.c:571:48: error: implicit declaration of
function 'gdPngGetVersionString' is invalid in C99
[-Werror,-Wimplicit-function-declaration]
        php_info_print_table_row(2, "libPNG Version", gdPngGetVersionString());
                                                      ^
/Users/flavio/Documents/open-source/php-src/ext/gd/gd.c:571:48: note: did you mean
'gdVersionString'?
/usr/local/include/gd.h:1687:27: note: 'gdVersionString' declared here
BGD_DECLARE(const char *) gdVersionString(void);



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=81032&edit=1


Thread (4 messages)

« previous php.bugs (#233803) next »