Magick++ Demo won't compile VS 2008

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
ackmm7

Magick++ Demo won't compile VS 2008

Post by ackmm7 »

I've tried searching for the answer to this problem but nothing of relevance has come up. I have been using Image Magic on Linux for some time and have had no troubles. Now that i'm trying the windows version I can't even compile any of the demo programs.

System Configuration
OS: Windows 7 64 bit
IDE: Visual Studio 2008
Image Magic: ImageMagick-6.6.5-7-Q16-windows-x64-dll.exe

Project Properties:
C/C++ -> Preprocessor:
NDEBUG
WIN32
_CONSOLE
_VISUALC_
NeedFunctionPrototypes
_DLL
_MAGICKMOD_

Linker -> Input:
CORE_RL_magick_.lib
CORE_RL_Magick++_.lib
CORE_RL_wand_.lib
X11.lib
odbc32.lib
odbccp32.lib
winmm.lib
wsock32.lib


Right now i'm just trying to compile the button project and I'm getting 25 errors after compiling. Here is the contents of the output window.

Code: Select all

1>Linking...

1>button.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>button.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>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::compressType(enum MagickCore::CompressionType)" (__imp_?compressType@Image@Magick@@QAEXW4CompressionType@MagickCore@@@Z) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::quantize(bool)" (__imp_?quantize@Image@Magick@@QAEX_N@Z) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::quantizeColors(unsigned int)" (__imp_?quantizeColors@Image@Magick@@QAEXI@Z) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::quantizeDither(bool)" (__imp_?quantizeDither@Image@Magick@@QAEX_N@Z) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::depth(unsigned int)" (__imp_?depth@Image@Magick@@QAEXI@Z) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::frame(class Magick::Geometry const &)" (__imp_?frame@Image@Magick@@QAEXABVGeometry@2@@Z) referenced in function _main

1>button.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>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::borderColor(class Magick::Color const &)" (__imp_?borderColor@Image@Magick@@QAEXABVColor@2@@Z) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::annotate(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,enum MagickCore::GravityType)" (__imp_?annotate@Image@Magick@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@W4GravityType@MagickCore@@@Z) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::fontPointsize(double)" (__imp_?fontPointsize@Image@Magick@@QAEXN@Z) referenced in function _main

1>button.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>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::fillColor(class Magick::Color const &)" (__imp_?fillColor@Image@Magick@@QAEXABVColor@2@@Z) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Magick::Color::Color(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0Color@Magick@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::texture(class Magick::Image const &)" (__imp_?texture@Image@Magick@@QAEXABV12@@Z) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Magick::Image::Image(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0Image@Magick@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::read(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?read@Image@Magick@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Magick::Geometry::~Geometry(void)" (__imp_??1Geometry@Magick@@QAE@XZ) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall Magick::Image::size(class 
Magick::Geometry const &)" (__imp_?size@Image@Magick@@QAEXABVGeometry@2@@Z) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Magick::Geometry::Geometry(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0Geometry@Magick@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main

1>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Magick::Image::Image(void)" (__imp_??0Image@Magick@@QAE@XZ) referenced in function _main

1>button.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>button.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl Magick::InitializeMagick(char const *)" (__imp_?InitializeMagick@Magick@@YAXPBD@Z) referenced in function _main

1>./button.exe : fatal error LNK1120: 24 unresolved externals

1>Build log was saved at "file://c:\Program Files\ImageMagick-6.6.5-Q16\Magick++_Demo\Release\button\BuildLog.htm"
1>button - 25 error(s), 0 warning(s)
Now I have tired a few things already such as installing the x86 and x64 VS 2008 redist. I'm really at wits end here and would love to get some help.

Thanks in advance,

~Keith
Wizzard

Re: Magick++ Demo won't compile VS 2008

Post by Wizzard »

I have installed ImageMagick and Visual Studio 2008 on a fresh system. And I have the following code:

#include <iostream>
#include <Magick++.h>

using namespace std;
using namespace Magick;

int main()
{
const char path[] = "C:\\logo.gif";

Image img;
img.read( path );
return 0;
}

It compiles, but when I run at line img.read( path ); it give me an access violation:
Unhandled exception at 0x1002461a in Test 01.exe: 0xC0000005: Access violation writing location 0x7928a858..

The Button project from Demo gives me the same error.
Can anybody help me?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Magick++ Demo won't compile VS 2008

Post by el_supremo »

@ackmm7:
Did you also point the IDE at your lib directory in Linker|General|Additional Library Directories. e.g. C:\Program Files\ImageMagick-6.6.5-7-Q16\lib

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
dproc
Posts: 19
Joined: 2010-09-14T20:39:15-07:00
Authentication code: 8675308

Re: Magick++ Demo won't compile VS 2008

Post by dproc »

FYI same thing happening with me. I had everything working a couple months ago with VS2008 and an earlier version of IM but I can't remember the details and I did at some point decide to build from source--can't remember why. Now the demos crash with the latest stuff. Unfortunately I don't have time to resolve it.
dlflannery
Posts: 6
Joined: 2011-04-05T16:33:10-07:00
Authentication code: 8675308

Re: Magick++ Demo won't compile VS 2008

Post by dlflannery »

Similar problems here. VS2008 and ImageMagick-6.6.9-3-Q8-windows-dll Win32 version on a Win7 64bit machine.
The Magick++_demo solution builds OK, (once it is upgraded to VS2008 project automatically at first load).
But none of the programs run. They create Windows-program-has-error message popups immediately after displaying the first console message (Read images ...), i.e. the first time it tries to load an image.

I'm assuming the Win32 DLL's should run on my 64bit platform -- that's the way it works for all other 32 bit programs.
But I also tried using a Win64 version, (ImageMagick-6.6.9-3-Q16-windows-x64-dll), and then it won't compile. I got the demo.cpp program to compile by changing the target platform from 32bit to 64bit but then it catches an exception when I run it as follows:
Read images ...
Caught exception: Magick: no decode delegate for this image format `t☻/☻' @ error/constitute.c/ReadImage/532
With either version the convert logo: and imdisplay tests work fine so I seem to have good installations.

I verified the ImageMagick installation folder is in the path in both cases.

I suspect this is some problem with the solution file that is converted from the older .dsw file supplied in the example. If anyone has got ImageMagick to work with VS2008 C++, I would appreciate some help. Thanks.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Magick++ Demo won't compile VS 2008

Post by el_supremo »

FYI: I have VS 2010 Pro and the button demo compiles and runs without error on 64-bit Win7 Pro with IM 6.6.8-6 2011-03-21 Q16.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
dlflannery
Posts: 6
Joined: 2011-04-05T16:33:10-07:00
Authentication code: 8675308

Re: Magick++ Demo won't compile VS 2008

Post by dlflannery »

el_supremo wrote:FYI: I have VS 2010 Pro and the button demo compiles and runs without error on 64-bit Win7 Pro with IM 6.6.8-6 2011-03-21 Q16.

Pete
hmm... So I either need VS2010 or maybe it's the binary you are using. I haven't found any downloads with the date in the name. Also is that a Win64 or Win32 binary? Or did you build from source? Did your IM demo package include a solution file (.sln) or was it the old .dsw that has to be converted when loaded into the IDE?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Magick++ Demo won't compile VS 2008

Post by el_supremo »

I haven't found any downloads with the date in the name
The date is part of the string returned when using the MagickWand function MagickGetVersion.
Also is that a Win64 or Win32 binary?
It's the win32 binary distribution.
Did your IM demo package include a solution file (.sln)
No, it was a .dsp file which I opened from within the IDE (File|Open|Project/Solution). It was in C:\program files (x86)\imagemagick-6.6.8-q16\Magick++_demo

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
dlflannery
Posts: 6
Joined: 2011-04-05T16:33:10-07:00
Authentication code: 8675308

Re: Magick++ Demo won't compile VS 2008

Post by dlflannery »

I built just as you did (opening demo.dsp in IDE, which did NOT trigger a project conversion). It built fine but when I run I get a crash and if I debug I get:

Unhandled exception at 0x6c7a438a in button.exe: 0xC0000005: Access violation writing location 0x02f6a03d.

Do you know where I could download the IM version you're using? Or do you think it's just not going to work with VS2008 ?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Magick++ Demo won't compile VS 2008

Post by el_supremo »

There is a site which archives previous versions of IM here: [url]http://image_magick.veidrodis.com/image_magick/binaries/[/url]

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
dlflannery
Posts: 6
Joined: 2011-04-05T16:33:10-07:00
Authentication code: 8675308

Re: Magick++ Demo won't compile VS 2008

Post by dlflannery »

el_supremo wrote:There is a site which archives previous versions of IM here: [url]http://image_magick.veidrodis.com/image_magick/binaries/[/url]

Pete
Thanks, I tried the demo build with the version you were using and got the same result (builds fine but access error at run time).

Would you recommend building IM from source? (I don't know what else to try.)
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Magick++ Demo won't compile VS 2008

Post by el_supremo »

I don't know if it would help to build from source but, like you, I don't know what else you could try.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
dlflannery
Posts: 6
Joined: 2011-04-05T16:33:10-07:00
Authentication code: 8675308

Progress!

Post by dlflannery »

I think I'm almost there. I built from source and the demo program seems to run OK except for about 50 identical copies of this message coming out:
Magick: unable to read font `@ghostscript_font_path@n019003l.pfb' @ error/annotate.c/RenderFreetype/1128.
When I built IM, I did not have GS installed and the demo program produced a huge slew of more complicated error messages. The above message is what occurs after I've installed GS.

Poking in the code I see that n019003 is for the Helvetica font. Also the type-ghostsript.xml file is present on the runtime dir and it also shows n019003 as the Helvetica font. However I don't find any individual font files, e.g., with .pfb extension, anywhere in the GS install folder system -- I thought it came with a bunch of standard fonts, including Helvetica (?).
EDIT: I found the .pfb font files in the IM folder system, but I can't figure out where to put them so demo.exe will find them. It looks like nt-base.c is looking up the GS font folder in the registry and the registry is pointng to a font folder in the GS installation folder system, one which wasn't installed. I created that font folder and put the .pfb files in there but it still didn't work. I tried hard-coding folders to sub for the registry lookup but that didn't work.

I get three demo_out_#.miff output (montage) files that appear reasonable, showing many operations, and with a text annotation beneath each image. The text appears to be a poorly rendered Courier font. I suspect that is where Helvetica should have been (?)

Also the validate program showed passing all 1876 tests, although it printed the following out of stderr:
Magick: unable to open module file `C:\Users\Dave\.magick\IM_MOD_RL_PCT_.dll': No such file or directory @ warning/module.c/GetMagickModulePath/813.
Magick: unable to open module file `C:\Users\Dave\.magick\IM_MOD_RL_RADIAL-GR_.dll': No such file or directory @ warning/module.c/GetMagickModulePath/813.
Magick: unable to open module file `C:\Users\Dave\.magick\IM_MOD_RL_RADIAL-GR_.dll': No such file or directory @ warning/module.c/GetMagickModulePath/813.
and indeed those DLL's are not in the bin dir.

Hmm.... Just noticed the `C:\Users\Dave\.magick\' dir in those messages. That dir doesn't even exist and all the DLL's that were built are on the bin dir.
aberent
Posts: 2
Joined: 2011-04-08T06:38:52-07:00
Authentication code: 8675308

Re: Magick++ Demo won't compile VS 2008

Post by aberent »

Hi,

I had a problem rather similar to this problem, and I think I have an explanation. On investigation I discovered that, on Windows, the format of std::string changes between Visual Studio versions and also seems to depend on the compiler options you use. This causes problems because the read() function takes a std::string argument. As a result a Magic++ application is only compatible with a Magic++ DLL built with exactly the same VS versions and compiler options.

If, for example, you build your application with VS2008 and the Magick++ DLL with VS2010, and then call img.read("logo.gif"):
1. "logo.gif" is converted to a VS2008 std::string by calling std::string's constructor. Because std::string is a templated class this is an inline function defined in the header files, and is hence dependent on the version of the header files used.
2. The resulting object is passed to read()
3. read() (or something it calls) attempts to interpret it as a VS2010 std::string, and gets confused, causing the crash.

The only solution I know to this is to avoid using the binary of Magick++ (since we don't know how this was built) and to build your own version of the Magick++ DLL with the same standard library version, compiler version and compiler options as your application, and to ensure that it is shipped with your application.

To fix this properly Magick++ would have to provide interfaces that avoided the need to pass templated objects across the DLL interface, by, for example, providing a Image::read(const char *) function. While this would be easy for read() it would need more of a rethink for functions that return templated objects (e.g. std::vector objects).


- Anthony
dlflannery
Posts: 6
Joined: 2011-04-05T16:33:10-07:00
Authentication code: 8675308

Re: Progress!

Post by dlflannery »

dlflannery wrote:I think I'm almost there. I built from source and the demo program seems to run OK except for about 50 identical copies of this message coming out:
Magick: unable to read font `@ghostscript_font_path@n019003l.pfb' @ error/annotate.c/RenderFreetype/1128.
When I built IM, I did not have GS installed and the demo program produced a huge slew of more complicated error messages. The above message is what occurs after I've installed GS.

Poking in the code I see that n019003 is for the Helvetica font. Also the type-ghostsript.xml file is present on the runtime dir and it also shows n019003 as the Helvetica font. However I don't find any individual font files, e.g., with .pfb extension, anywhere in the GS install folder system -- I thought it came with a bunch of standard fonts, including Helvetica (?).
EDIT: I found the .pfb font files in the IM folder system, but I can't figure out where to put them so demo.exe will find them. It looks like nt-base.c is looking up the GS font folder in the registry and the registry is pointng to a font folder in the GS installation folder system, one which wasn't installed. I created that font folder and put the .pfb files in there but it still didn't work. I tried hard-coding folders to sub for the registry lookup but that didn't work.

I get three demo_out_#.miff output (montage) files that appear reasonable, showing many operations, and with a text annotation beneath each image. The text appears to be a poorly rendered Courier font. I suspect that is where Helvetica should have been (?)

Also the validate program showed passing all 1876 tests, although it printed the following out of stderr:
Magick: unable to open module file `C:\Users\Dave\.magick\IM_MOD_RL_PCT_.dll': No such file or directory @ warning/module.c/GetMagickModulePath/813.
Magick: unable to open module file `C:\Users\Dave\.magick\IM_MOD_RL_RADIAL-GR_.dll': No such file or directory @ warning/module.c/GetMagickModulePath/813.
Magick: unable to open module file `C:\Users\Dave\.magick\IM_MOD_RL_RADIAL-GR_.dll': No such file or directory @ warning/module.c/GetMagickModulePath/813.
and indeed those DLL's are not in the bin dir.

Hmm.... Just noticed the `C:\Users\Dave\.magick\' dir in those messages. That dir doesn't even exist and all the DLL's that were built are on the bin dir.
Bump...... Any suggestions on this Ghostscript font problem?
Post Reply