1

I was using Mac OS 12 and Perlbrew with Perl 5.36.

When I install GD using either CPAN or cpanm I get the following error:

cpanm (App::cpanminus) 1.7046 on perl 5.036000 built for darwin-2level
Work directory is /Users/mjb/.cpanm/work/1673722431.48328
You have make /usr/bin/make
You have LWP 6.67
You have /usr/bin/tar: bsdtar 3.5.1 - libarchive 3.5.1 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8 
You have /usr/bin/unzip
Searching install () on cpanmetadb ...
install is up to date. (0.01)
Searching GD () on cpanmetadb ...
--> Working on GD
Fetching http://www.cpan.org/authors/id/R/RU/RURBAN/GD-2.76.tar.gz
-> OK
Unpacking GD-2.76.tar.gz
Entering GD-2.76
Checking configure dependencies from META.json
Checking if you have ExtUtils::Constant 0.22 ... Yes (0.25)
Checking if you have ExtUtils::PkgConfig 0 ... Yes (1.16)
Configuring GD-2.76
Running Makefile.PL
Notice: Type perl Makefile.PL -h for command-line option summary.

Package gdlib was not found in the pkg-config search path.
Perhaps you should add the directory containing `gdlib.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gdlib' found
 at Makefile.PL line 530.
*** can not find package gdlib
*** check that it is properly installed and available in PKG_CONFIG_PATH
 at Makefile.PL line 530.
-> N/A
-> FAIL Configure failed for GD-2.76. See /Users/mjb/.cpanm/work/1673722431.48328/build.log for details.

The above is the contents of build.log. I'm not sure how to investigate further or fix it.

Previously I had Perl's GD install and build using the system Perl. I also have libgd installed from Homebrew and I included /usr/local/lib in the env var PKG_CONFIG_PATH. Still no avail.

Would appreciate help as I rely upon GD for my personal projects. Thanks.

thran
  • 137
  • 10
  • 2
    Did you try this answer: https://stackoverflow.com/a/65281748/2173773 – Håkon Hægland Jan 28 '23 at 15:52
  • Did you install just the library, or the dev files (.h files) too? – ikegami Jan 28 '23 at 20:37
  • @HåkonHægland, sorry that didn't work. I have both pkg-config and libgd installed. @ikegami I installed this: https://formulae.brew.sh/formula/gd#default it appears to be the only `gd` package on Homebrew. I haven't found any `gd.h` or `gd_color.h` files on my Mac. – thran Jan 28 '23 at 22:45
  • @thran Can you try to download the tar ball for GD https://cpan.metacpan.org/authors/id/R/RU/RURBAN/GD-2.76.tar.gz, and then run `perl Makefile.PL` from the distribution directory? When I do that (macOS 13.1, M1, perlbrew perl 5.34) I get this output: https://pastebin.com/QHx6vZWr – Håkon Hægland Jan 28 '23 at 22:53
  • @HåkonHægland I ran it and got the same error message as above. Though when I searched my mac for `gdlib.pc` it wasn't present - is this file in your system? – thran Jan 29 '23 at 12:27
  • @thran Yes they are present: `/opt/homebrew/Cellar/gd/2.3.3_3/lib/pkgconfig/gdlib.pc` and `/opt/homebrew/Cellar/gd/2.3.3_3/include/gd.h`. Maybe your PATH is not correctly setup? What is the output of `echo $PATH | perl -nE 'say for split ":"' | grep homebrew` ? – Håkon Hægland Jan 29 '23 at 14:23
  • @HåkonHægland Interestingly I found gdlib.pc here: `/usr/local/Cellar/gd/2.3.3_4/lib/pkgconfig`. homebrew didn't appear in any of the `$PATH` vars... also `$PKG_CONFIG_PATH` has nothing. Is it failing to be set during the build process? – thran Jan 30 '23 at 22:56
  • Fixed it, see my solution below. Thanks for your patience @HåkonHægland – thran Jan 30 '23 at 23:13

1 Answers1

2

Found it... something (probably me botching my .zshrc) had unset my $PKG_CONFIG_PATH!

After finding out what pkg-config was and scouring my drive for any telling collection of .pc files, I found gdlib.pc under /usr/local/lib/pkgconfig/gdlib.pc.

Then I simply did an export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ and reran the installation. Perl's GD built and installed without grumbling.

A pernanment solution will be to add the above line to your ~/.zshrc.

thran
  • 137
  • 10