簡體   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