繁体   English   中英

Magick++ - 对符号“ImagesToBlob”的未定义引用

[英]Magick++ - undefined reference to symbol 'ImagesToBlob'

我是 C++ 新手,我最近在 WSL2 上安装了 magick++,以便在带有 cmake 的 c++ 项目中使用它,但是当我尝试使用它时,它显示了一个错误。

我已经尝试了很多东西。

我是如何安装magick++的

sudo apt-get install -y libmagick++-dev

我的 cmake 文件

...

# Linking libraries
find_package(PkgConfig REQUIRED)

pkg_search_module(dpp REQUIRED dpp)
target_link_libraries(${PROJECT_NAME} dpp)

add_definitions(-DMAGICKCORE_QUANTUM_DEPTH=16)
add_definitions(-DMAGICKCORE_HDRI_ENABLE=1)
find_package(ImageMagick COMPONENTS Magick++)
include_directories(${ImageMagick_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${ImageMagick_LIBRARIES})

# Set C++ version
set_target_properties(${PROJECT_NAME} PROPERTIES
        CXX_STANDARD 20
        CXX_STANDARD_REQUIRED ON
        )

我的代码

int width = 300;
int height = 200;
vector<Image> frames;

for (int i=0;i<20;i++) {
    Geometry newSize(width, height);
    Image img(newSize, Color("black"));
    img.draw({
        DrawableFont("Helvetica"),
        DrawableText(width / 3, height / 2, to_string(i)),
        DrawableStrokeColor(Color("white")),
        DrawableFillColor(Color("blue"))
    });
    img.animationDelay(1000 / 20);
    img.magick("GIF");
    frames.push_back(img);
}
Blob blob;
writeImages(frames.begin(), frames.end(), &blob);
event.reply(dpp::message().add_file("test.gif", blob.base64()));

错误

[ 16%] Linking CXX executable Pixi-battle
/usr/bin/ld: CMakeFiles/Pixi-battle.dir/src/models/command/commands/test.cpp.o: undefined reference to symbol 'ImagesToBlob'
/usr/bin/ld: /lib/x86_64-linux-gnu/libMagickCore-6.Q16.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/Pixi-battle.dir/build.make:145: Pixi-battle] Error 1
make[2]: *** [CMakeFiles/Makefile2:76: CMakeFiles/Pixi-battle.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/Pixi-battle.dir/rule] Error 2
make: *** [Makefile:140: Pixi-battle] Error 2

我需要安装libmagickcore-dev

sudo apt install -y libmagickcore-dev

并将MagickCore添加到这样的 cmake 组件中

find_package(ImageMagick COMPONENTS Magick++ MagickCore)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM