【发布时间】:2013-01-02 15:51:48
【问题描述】:
我最近为 C++ 安装了 ImageMagick 库。我之前没有使用 C++ GUI 的经验,但我非常擅长 C++ 命令行编程。
我已经通过 .exe 文件在 Windows 中安装了 ImageMagick,并将库和头文件复制到 C++,但是每当我尝试运行任何演示程序时,我总是会收到此错误:
1>------ Build started: Project: Sufiyan, Configuration: Debug Win32 ------
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Magick::Image::~Image(void)" (__imp_??1Image@Magick@@UAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::write(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?write@Image@Magick@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::pixelColor(long,long,class Magick::Color const &)" (__imp_?pixelColor@Image@Magick@@QAEXJJABVColor@2@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall Magick::Color::~Color(void)" (__imp_??1Color@Magick@@UAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Magick::Geometry::~Geometry(void)" (__imp_??1Geometry@Magick@@QAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Magick::Image::Image(class Magick::Geometry const &,class Magick::Color const &)" (__imp_??0Image@Magick@@QAE@ABVGeometry@1@ABVColor@1@@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Magick::Geometry::Geometry(char const *)" (__imp_??0Geometry@Magick@@QAE@PBD@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Magick::Color::Color(char const *)" (__imp_??0Color@Magick@@QAE@PBD@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl Magick::InitializeMagick(char const *)" (__imp_?InitializeMagick@Magick@@YAXPBD@Z) referenced in function _main
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\Z-Axis\documents\visual studio 2010\Projects\Sufiyan\Debug\Sufiyan.exe : fatal error LNK1120: 10 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
这些是我的笔记本电脑规格:
- Windows 7 64 位。
- Visual C++ 2010 Express x86
- ImageMagick x86
这就是我尝试安装它的方式:
- 已安装 Visual C++ 2010 Express
- 已安装 ImageMagick
- 复制 ImageMagick Lib 并包含在 Visual C++ 2010 中
- 已选择 Win32 -> Windows -> 空项目(无效)
- 选定的 Win32 -> DLL(不起作用)
- 已选择 Win32 -> 静态(无效)
但是当我运行任何代码时,它会给出上述错误。
有人提出了这个解决方案:
你需要一个起点,去
c:\Program Files\ImageMagick-6.8.1-Q16\Magick++_demos.
单击按钮工作区,构建并运行。
假设成功,请将按钮工作区用作您自己的自定义代码的模板。
我也试了几十次了,一直报这个错误:
项目必须转换为当前的 Visual C++ 项目格式。
转换后,您将无法在以前版本的 Visual Studio 中编辑此项目。 转换并打开这个项目?
当我单击 Yes 时,什么也没有发生,屏幕上什么也没有显示 - 空白的 Visual C++ 屏幕,没有打开项目。
我非常想知道:是什么导致了这个错误,为什么演示程序也不能工作?
【问题讨论】:
-
您需要提供编译 ImageMagick 库来导入这些方法。
-
@Ramhound 你能详细说明一下吗?我所做的只是复制 lib 并包含在 Visual C++ VC 文件夹中,它们可以在代码中使用(当我按 CTRL+SPACE 时)编译 ImageMagick 库是什么意思?