### ImageMagick version

7.1.1

### Operating system

Windows

### Operating system, version and so on

MSYS2

### Description

Trying to build on Windows 11 with gcc and perl version 5.38.0, the linker gives `undefined reference to BZ2_bzerror` when linking `MagickCore/libMagickCore-7.Q16HDRI.la`.

# Steps to reproduce:

## Install Strawberry Perl 5.38.0
Go to: https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases
- Download
https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit.msi
- Double click on the file to start the installation
- Install to C:\\Strawberry folder

## Install MSYS2

- Downloaded the 64-bit installer from https://www.msys2.org/wiki/MSYS2-installation/
- Install into `C:\msys2` (or choose some other path)

## Install ImageMagick

- In the MSYS2 terminal window
```
$ git clone --depth=1 https://github.com/ImageMagick/ImageMagick
$ cd ImageMagick
$ export PATH=/c/Strawberry/c/bin:$PATH
$ ./configure --with-perl=/c/Strawberry/perl/bin/perl.exe prefix=/c/Strawberry/c CPPFLAGS="-IC:/Strawberry/c/include -IC:/Strawberry/c/include/ImageMagick-7" LDFLAGS="-LC:/Strawberry/c/lib" 2>&1 | tee configure_log.txt
$ make 2>&1 | tee make_log.txt
[...]
  CC       coders/MagickCore_libMagickCore_7_Q16HDRI_la-jpeg.lo
  CC       filters/MagickCore_libMagickCore_7_Q16HDRI_la-analyze.lo
  CCLD     MagickCore/libMagickCore-7.Q16HDRI.la
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: MagickCore\\.libs\\libMagickCore_7_Q16HDRI_la-blob.o: in function `EOFBlob':
C:\msys2\home\hakon\ImageMagick/MagickCore/blob.c:1270: undefined reference to `BZ2_bzerror'
[...]
```
The complete log files from the build: [configure_log.txt](https://github.com/ImageMagick/ImageMagick/files/12872758/configure_log.txt) and [make_log.txt](https://github.com/ImageMagick/ImageMagick/files/12872760/make_log.txt)

See also https://github.com/ImageMagick/ImageMagick/discussions/6766


### Steps to Reproduce

See description

### Images

_No response_
Windows 11: building with gcc and perl support : `undefined reference to BZ2_bzerror`
This is a GitHub Issue
repo:ImageMagick
owner:ImageMagick
Title : Windows 11: building with gcc and perl support : `undefined reference to BZ2_bzerror`
Issue date:

--- start body ---
### ImageMagick version

7.1.1

### Operating system

Windows

### Operating system, version and so on

MSYS2

### Description

Trying to build on Windows 11 with gcc and perl version 5.38.0, the linker gives `undefined reference to BZ2_bzerror` when linking `MagickCore/libMagickCore-7.Q16HDRI.la`.

# Steps to reproduce:

## Install Strawberry Perl 5.38.0
Go to: https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases
- Download
https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit.msi
- Double click on the file to start the installation
- Install to C:\\Strawberry folder

## Install MSYS2

- Downloaded the 64-bit installer from https://www.msys2.org/wiki/MSYS2-installation/
- Install into `C:\msys2` (or choose some other path)

## Install ImageMagick

- In the MSYS2 terminal window
```
$ git clone --depth=1 https://github.com/ImageMagick/ImageMagick
$ cd ImageMagick
$ export PATH=/c/Strawberry/c/bin:$PATH
$ ./configure --with-perl=/c/Strawberry/perl/bin/perl.exe prefix=/c/Strawberry/c CPPFLAGS="-IC:/Strawberry/c/include -IC:/Strawberry/c/include/ImageMagick-7" LDFLAGS="-LC:/Strawberry/c/lib" 2>&1 | tee configure_log.txt
$ make 2>&1 | tee make_log.txt
[...]
  CC       coders/MagickCore_libMagickCore_7_Q16HDRI_la-jpeg.lo
  CC       filters/MagickCore_libMagickCore_7_Q16HDRI_la-analyze.lo
  CCLD     MagickCore/libMagickCore-7.Q16HDRI.la
C:/Strawberry/c/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: MagickCore\\.libs\\libMagickCore_7_Q16HDRI_la-blob.o: in function `EOFBlob':
C:\msys2\home\hakon\ImageMagick/MagickCore/blob.c:1270: undefined reference to `BZ2_bzerror'
[...]
```
The complete log files from the build: [configure_log.txt](https://github.com/ImageMagick/ImageMagick/files/12872758/configure_log.txt) and [make_log.txt](https://github.com/ImageMagick/ImageMagick/files/12872760/make_log.txt)

See also https://github.com/ImageMagick/ImageMagick/discussions/6766


### Steps to Reproduce

See description

### Images

_No response_
--- end body ---
