【问题标题】:Read function in magick++ wont compileMagick++ 中的读取函数无法编译
【发布时间】:2015-08-28 00:49:02
【问题描述】:
#include <iostream>
#include <Magick++.h>

int main()
{
    Magick::InitializeMagick(NULL);
    Magick::Image im;
    im.read("/home/chase/Desktop/m42.jpg");
    im.display();
    return 0;
}

当我尝试在 eclipse 中编译时出现以下错误...

Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -std=c++0x -I/usr/include/x86_64-linux-gnu/ImageMagick-6 -I/usr/include/ImageMagick-6 -O0 -g3 -Wall -c -fmessage-length=0 -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
Finished building: ../main.cpp

Building target: Stacking
Invoking: GCC C++ Linker
g++ -L../ -o "Stacking"  ./main.o   -lMagick++-6.Q16 -lMagickWand-6.Q16 -lMagickCore-6.Q16 -lMagick++-6.Q16 -lMagickWand-6.Q16 -lMagickCore-6.Q16
./main.o: In function `main':
/home/chase/workspace/Stacking/Debug/../main.cpp:8: undefined reference to `Magick::Image::read(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
makefile:44: recipe for target 'Stacking' failed
make: *** [Stacking] Error 1

为什么读取函数无法编译。我使用 eclipse 中的包配置工具来设置 Magick++。据我所知,所有其他功能都可以正常工作。我正在使用 Ubuntu。我使用 sudo apt-get install libmagick++-dev 安装了 Magic++。

更新: 我让它工作。我已经升级到 g++-5。当我用 g++-4.9 编译时,它起作用了。想知道为什么它不适用于 g++-5?

【问题讨论】:

    标签: c++ g++


    【解决方案1】:

    为什么读取函数没有编译

    您的read 函数确实编译。你有一个链接问题。

    为什么它不适用于 g++-5

    因为g++-4.xg++-5.x 使用不同的ABI,并且链接兼容(并且您的libMagick* 库是使用g++-4.x 构建的)。

    【讨论】:

    • 有没有办法为g++-5重新编译Magick++。或者获得一个可以使用它的版本?
    • @chasep255 当然:Magic++ 是开源的,所以你可以下载并使用g++-5.x 编译它。在此处查看“从源代码构建”:imagemagick.org/Magick++/Install.html
    猜你喜欢
    • 1970-01-01
    • 2023-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多