问题
I have recently installed ImageMagick libraries for C++. I have no prior experience with C++ GUI but I'm very good in C++ command line programming.
I have installed ImageMagick in Windows through an .exe file and copied libraries and header files to C++ but whenever I try to run any demo program I am consistently getting this error:
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 ==========
These are my laptop Specs:
- Windows 7 64 bit.
- Visual C++ 2010 Express x86
- ImageMagick x86
This is how I tried installing it:
- Installed Visual C++ 2010 Express
- Installed ImageMagick
- Copy ImageMagick Lib and Includes in Visual C++ 2010
- Selected Win32 -> Windows -> Empty project (didn't work)
- Selected Win32 -> DLL (didn't work)
- Selected Win32 -> Static (didn't work)
but when I run any code it gives the error mentioned above.
Someone has suggested this solution:
You need a starting point, go to
c:\Program Files\ImageMagick-6.8.1-Q16\Magick++_demos.
Click on the button workspace, build, and run.
Assuming that's successful, use the button workspace as a template for your own custom code.
I've tried this too, dozens of times, and am continuously getting this error:
The Project must be Converted to current Visual C++ project format.
After it has been converted you will not be able to edit this project in previous version of visual studio. Convert and open this project ?
When I click Yes
nothing happens, nothing shows on the screen - blank Visual C++ screen with no project open.
I desperately want to know: What is causing this error and why even the demo programs are not working?
回答1:
Try to build ImageMagick yourself, the problem may come form the different version of compiler.
Follow the directions in Advanced windows installation of ImageMagick. At end of the above page, there is a solution of link error, make sure you have set the preprocessor. I just followed it to build a project successfully.
来源:https://stackoverflow.com/questions/14407353/installing-magick-in-visual-c-2010