### ImageMagick version

7.1.1.11-1 (Magick++)

### Operating system

Windows

### Operating system, version and so on

Windows10 22H2

### Description

I am currently working with Magick++ (installed on Msys2: `mingw-w64-x86_64-imagemagick 7.1.1.11-1` ) on C++, and trying running the example code (which is slightly modified), which is an example of how frames from a GIF animation be appended horizontally with the resulting image written to the file. I found that when I trying to run the generated executable, no any new image will be generated, and the execution also got stuck unless I kill the terminal.

![image](https://github.com/ImageMagick/ImageMagick/assets/76443690/d859ca46-6d73-4bb4-8e04-02dc2570f5c3)
Just stuck there eternally like shown above.

### Steps to Reproduce

1. install Magick++ library and header from Msys2 by `pacman -S mingw-w64-x86_64-imagemagick`
2. download any animated gif and rename it to `example.gif` and place into the `build` folder of the project
3. use CMake tools (with CMake 3.26.0) in VSCode and generate new project with the following CMakeLists
```cmake
cmake_minimum_required(VERSION 3.0.0)
project(imgk VERSION 0.1.0 LANGUAGES C CXX)

include(CTest)
enable_testing()

find_package(ImageMagick COMPONENTS REQUIRED Magick++ MagickCore MagickWand)

find_program(MAGICK_CONFIG "Magick++-config")
execute_process(COMMAND "${MAGICK_CONFIG}" "--cxxflags" OUTPUT_VARIABLE MAGICK_CXX_FLAGS)
execute_process(COMMAND "${MAGICK_CONFIG}" "--cppflags" OUTPUT_VARIABLE MAGICK_CPP_FLAGS)
execute_process(COMMAND "${MAGICK_CONFIG}" "--ldflags" OUTPUT_VARIABLE MAGICK_LD_FLAGS)
execute_process(COMMAND "${MAGICK_CONFIG}" "--libs" OUTPUT_VARIABLE MAGICK_LIBS_FLAGS)

string(STRIP "${MAGICK_CXX_FLAGS}" MAGICK_CXX_FLAGS)
string(STRIP "${MAGICK_LD_FLAGS}" MAGICK_LD_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 ${MAGICK_CXX_FLAGS} ${MAGICK_LIBS_FLAGS} ${MAGICK_CPP_FLAGS} ${MAGICK_LD_FLAGS}")

add_executable(imgk main.cpp)

add_definitions( -DMAGICKCORE_QUANTUM_DEPTH=16 )
add_definitions( -DMAGICKCORE_HDRI_ENABLE=0 )
include_directories(${ImageMagick_INCLUDE_DIRS})
target_link_libraries(imgk ${ImageMagick_LIBRARIES})

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
```
4. choose compiler as gcc 13.1.0 x86_64 (mingw)
5. build the project with the following code that copied and modified from [https://imagemagick.org/Magick++/STL.html](url)
```cpp
#include <iostream>
#include <vector>
#include <Magick++.h>

using namespace std;
using namespace Magick;

int main(){
    vector<Image> frames; 
    Image appended; 
    readImages(&frames, "example.gif");
    appendImages(&appended, frames.begin(), frames.end());
    appended.write("new_img.gif");
    return 0; 
}
```
6. the execution will never end and just stuck eternally, no new image "new_img.gif" will be generated.


### Images

![example](https://github.com/ImageMagick/ImageMagick/assets/76443690/92e37b11-485c-4736-ad30-9ee2a8fdbc86)

In my case, any animated .gif image will also generated the same result, so I randomly send a gif here

Magick++ project executable unable to finish execution
This is a GitHub Issue
repo:ImageMagick
owner:ImageMagick
Title : Magick++ project executable unable to finish execution
Issue date:

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

7.1.1.11-1 (Magick++)

### Operating system

Windows

### Operating system, version and so on

Windows10 22H2

### Description

I am currently working with Magick++ (installed on Msys2: `mingw-w64-x86_64-imagemagick 7.1.1.11-1` ) on C++, and trying running the example code (which is slightly modified), which is an example of how frames from a GIF animation be appended horizontally with the resulting image written to the file. I found that when I trying to run the generated executable, no any new image will be generated, and the execution also got stuck unless I kill the terminal.

![image](https://github.com/ImageMagick/ImageMagick/assets/76443690/d859ca46-6d73-4bb4-8e04-02dc2570f5c3)
Just stuck there eternally like shown above.

### Steps to Reproduce

1. install Magick++ library and header from Msys2 by `pacman -S mingw-w64-x86_64-imagemagick`
2. download any animated gif and rename it to `example.gif` and place into the `build` folder of the project
3. use CMake tools (with CMake 3.26.0) in VSCode and generate new project with the following CMakeLists
```cmake
cmake_minimum_required(VERSION 3.0.0)
project(imgk VERSION 0.1.0 LANGUAGES C CXX)

include(CTest)
enable_testing()

find_package(ImageMagick COMPONENTS REQUIRED Magick++ MagickCore MagickWand)

find_program(MAGICK_CONFIG "Magick++-config")
execute_process(COMMAND "${MAGICK_CONFIG}" "--cxxflags" OUTPUT_VARIABLE MAGICK_CXX_FLAGS)
execute_process(COMMAND "${MAGICK_CONFIG}" "--cppflags" OUTPUT_VARIABLE MAGICK_CPP_FLAGS)
execute_process(COMMAND "${MAGICK_CONFIG}" "--ldflags" OUTPUT_VARIABLE MAGICK_LD_FLAGS)
execute_process(COMMAND "${MAGICK_CONFIG}" "--libs" OUTPUT_VARIABLE MAGICK_LIBS_FLAGS)

string(STRIP "${MAGICK_CXX_FLAGS}" MAGICK_CXX_FLAGS)
string(STRIP "${MAGICK_LD_FLAGS}" MAGICK_LD_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 ${MAGICK_CXX_FLAGS} ${MAGICK_LIBS_FLAGS} ${MAGICK_CPP_FLAGS} ${MAGICK_LD_FLAGS}")

add_executable(imgk main.cpp)

add_definitions( -DMAGICKCORE_QUANTUM_DEPTH=16 )
add_definitions( -DMAGICKCORE_HDRI_ENABLE=0 )
include_directories(${ImageMagick_INCLUDE_DIRS})
target_link_libraries(imgk ${ImageMagick_LIBRARIES})

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
```
4. choose compiler as gcc 13.1.0 x86_64 (mingw)
5. build the project with the following code that copied and modified from [https://imagemagick.org/Magick++/STL.html](url)
```cpp
#include <iostream>
#include <vector>
#include <Magick++.h>

using namespace std;
using namespace Magick;

int main(){
    vector<Image> frames; 
    Image appended; 
    readImages(&frames, "example.gif");
    appendImages(&appended, frames.begin(), frames.end());
    appended.write("new_img.gif");
    return 0; 
}
```
6. the execution will never end and just stuck eternally, no new image "new_img.gif" will be generated.


### Images

![example](https://github.com/ImageMagick/ImageMagick/assets/76443690/92e37b11-485c-4736-ad30-9ee2a8fdbc86)

In my case, any animated .gif image will also generated the same result, so I randomly send a gif here

--- end body ---
