magick++ 中的读取函数不会编译
Read function in magick++ wont compile
#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?
Why does the read function not compile
您的 read
函数 确实 编译。你遇到的是 link 问题。
why it does not work with g++-5
因为 g++-4.x
和 g++-5.x
使用不同的 ABI,并且 不 link 兼容(并且您的 libMagick*
库是用 g++-4.x
) 构建的。
#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?
Why does the read function not compile
您的 read
函数 确实 编译。你遇到的是 link 问题。
why it does not work with g++-5
因为 g++-4.x
和 g++-5.x
使用不同的 ABI,并且 不 link 兼容(并且您的 libMagick*
库是用 g++-4.x
) 构建的。