php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81032 GD install is affected by external libgd installation
Submitted: 2021-05-11 23:51 UTC Modified: 2021-05-12 11:57 UTC
From: flaviohbatista at gmail dot com Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: Irrelevant OS: MacOS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: flaviohbatista at gmail dot com
New email:
PHP Version: OS:

 

 [2021-05-11 23:51 UTC] 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);


Patches

gd.patch (last revision 2021-05-11 23:51 UTC by flaviohbatista at gmail dot com)

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-11 23:57 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2021-05-12 09:39 UTC] cmb@php.net
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
 [2021-05-12 11:57 UTC] cmb@php.net
-Status: Assigned +Status: Analyzed
 [2021-05-14 10:28 UTC] git@php.net
Automatic comment on behalf of flavioheleno (author) and cmb69 (committer)
Revision: https://github.com/php/php-src/commit/28e7addb9dfd2280c2f9e6990d353070321c69e7
Log: Fix #81032: GD install is affected by external libgd installation
 [2021-05-14 10:28 UTC] git@php.net
-Status: Analyzed +Status: Closed
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Apr 13 01:01:29 2025 UTC