I want to try writing some C++ image processing script by using the Magick++ library (on Windows10), so I just installed the ImageMagick 7.1.1-12 (ImageMagick-7.1.1-12-Q16-HDRI-x64-dll.exe) from their official download page, and installed along with the development headers and libraries for C and C++.
Here is my installation path: E:\Programs\ImageMagick-7.1.1-Q16-HDRI
Therefore the C++ headers and libraries are automatically installed under E:\Programs\ImageMagick-7.1.1-Q16-HDRI\include and E:\Programs\ImageMagick-7.1.1-Q16-HDRI\lib respectively.
I try to run some code to test my installation:
#include <iostream>
#include "Magick++.h"
int main(int argc,char **argv)
{
Magick::InitializeMagick("E:\\Programs\\ImageMagick-7.1.1-Q16-HDRI");
return 0;
}
and build it with g++ 13.1.0 as follow in powershell:
g++.exe main.cpp -o main.exe -IE:\Programs\ImageMagick-7.1.1-Q16-HDRI\include -LE:\Programs\ImageMagick-7.1.1-Q16-HDRI\lib -lCORE_RL_Magick++_ -lCORE_RL_MagickCore_ -lCORE_RL_MagickWand_
What I got is the following error message: undefined reference to Magick::InitializeMagick(char const*)
Apart from installing the header and library by ImageMagick-7.1.1-12-Q16-HDRI-x64-dll.exe, I have also attempted to install Magick++ from Msys2 (mingw-w64-x86_64-imagemagick 7.1.1.11-1) and tried to use CMake tool on VSCode to build the project, CMakeLists as follow:
cmake_minimum_required(VERSION 3.0.0)
project(imgk VERSION 0.1.0 LANGUAGES C CXX)
include(CTest)
enable_testing()
find_package(ImageMagick COMPONENTS Magick++ REQUIRED)
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)
But the building process also failed for the same reason as above