Installing PerlMagick 6.3.7 with Visual Studio 2005 (VC++8)

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Installing PerlMagick 6.3.7 with Visual Studio 2005 (VC++8)

Post by rmabry »

Note to self: This is how I finally got PerlMagick running on Windows under Visual Studio 2005 (VC++ 8), after two days of aggravation and cursing. In short, the problems were manifest. But the solution was, in the end, easy. The path to the solution was along a road through Microsoft Hell (specifically called DLL Hell, now also Manifest Hell) and the web is filled with similar complaints and strange fixes and explanations. I will not claim this to be a clean fix, but I'm pretty sure it isn't dangerous.

The situation is this: As of this date (5 Dec 2007) Visual Studio 2005 isn't (I believe) supported yet by ImageMagick (6.3.7). But I am stuck using VS 2005, so I had to try make it work.

First, it was a relief that ImageMagick itself (minus PerlMagick) built with no errors, using the usual VisualMagick configure process. There was a brief moment of doubt when told that the VC++7 project files would have to be converted for VC++8, but that was expected and already familiar from the last upgrade (from VC++6 to VC++7).

To build PerlMagick, I can still use (and have used with VC++7) the following process, modified from that given in the PerlMagick docs (README.txt). I note here that the instructions given in that file are incomplete and scant for Windows users --- Y.A.W.P. (Yet Another Windows Punishment). Actually, the help for Windows users is, in its entirety, the following few lines, nestled midway in the file. It should at least be at the top.
For Windows systems, type

perl Makefile.nt
nmake install
That's all you get. And it often does not work, as other posts on these boards attest. The steps that are described below are what I have used with success.

I'm assuming that an appropriate version of Perl is installed and that Perl, ImageMagick and Visual Studio are set up in standard, "out-of-the-box" ways.

Open a cmd shell in the PerlMagick directory.

First run (at the command prompt),

vcvars32

to execute the vcvars32.bat script that lives in the VC/bin folder of Visual Studio. If it isn't found, you need to add that VC/bin to your PATH environmental variable, which I do via the Control Panel (System/Advanced/Environmental Variables), so that the PATH is set whenever cmd.exe is launched. (And then you'll have to restart a fresh cmd shell.) On my system the full path is

%SystemDrive%\Program Files\Microsoft Visual Studio 8\VC\bin

where SystemDrive is another environmental variable that Windows seems to set. Usually it is just "C:" so you could just use that:

C:\Program Files\Microsoft Visual Studio 8\VC\bin

Anyway, vcvars32.bat sets a bunch of environmental variables that enable VC programs to run from the commandline and to let various libraries be found by the linker.

Next, edit (with an ASCII text editor) the file Makefile.nt to change the line

Code: Select all

    
'LIBS'      => ['-L..\VisualMagick\lib -L..\VisualMagick\bin -lCORE_RL_magick_.lib'],
by adding the debug library to the list (Debug is, after all, the default build configuration; you can skip this if you always do the Release build):

Code: Select all

    'LIBS'      => ['-L..\VisualMagick\lib -L..\VisualMagick\bin -lCORE_RL_magick_.lib  -lCORE_DB_magick_.lib'],
(Obviously, you should not have to do the step above, but I haven't noticed another way, short of always using the Release version.)

NOW you're finally ready to run,

perl Makefile.nt

It will give some warnings and complain that one of the libraries isn't found (because you haven't built both Release and Debug). Don't worry about it.

Now you can run

nmake install

and PerlMagick should be built.

At this point you should try to run one of the PerlMagick scripts in the demo folder, such as shapes.pl, so go ahead and try if you're feeling lucky so far.

cd demo
perl shapes.pl


If it works, then perhaps you are from the future and running Visual Studio 2525 and Windows has survived. But all I got was this lousy error message:
perl.exe - Unable to Locate Component
This application has failed to start because MSVCR80.dll was not found.
Re-installing the application may fix this problem.


Like this one, but with "perl.exe" in place of "app.exe" (apologies for stealing bandwidth from elsewhere):

Image

What a useless error message this is. It turns out that the error arises because perl.exe lacks a "manifest", which is something new to me, something I do not understand, and something I have no intention of understanding. Ever. Its invention, probably intended for good, is instead robbing the human race of thousands of hours of otherwise useful human life, if a search on the error message is to be believed. And I believe it.

Here is the "solution" I finally arrived at, which comes partly from the advice of "oshah" on the website www.dll-files.com and partly from www.grimes.demon.co.uk and part I made up:

The build of Perlmagick created Magick.dll in the folder PerlMagick\blib\arch\auto\Image\Magick, along with a file called Magick.dll.manifest. Just copy that manifest file to the folder containing perl.exe (perhaps it is in C:\perl\bin) and rename it to perl.exe.manifest.

That worked for me. It can't be a good solution, but these are not good times if manifests are our destiny. I hope this long-winded solution-rant helps some poor soul. Better still would be a real solution to the problem or a cleaner version of the one posted here. I suspect this will be taken care of when ImageMagick hooks up fully with VS 2005.

Rick
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Re: Installing PerlMagick 6.3.7 with Visual Studio 2005 (VC++8)

Post by rmabry »

Reply to self:

A fix is in the works at Perl:

http://www.nntp.perl.org/group/perl.per ... 22188.html
Various problems encountered when building perl with Visual Studio 2005
(aka VC++ 8) have already been fixed in the latest development version
of perl, including issues with the manifest files, which are now
actually embedded in the executables and DLL's. See changes #29266 and
#29374:

http://public.activestate.com/cgi-bin/p ... se/p/29266
http://public.activestate.com/cgi-bin/p ... se/p/29374

Please try the latest development version if you can (or otherwise wait
until the release of 5.10) and create another bug report if you have any
problems building that with VC++ 8. (The fixes will also probably be in
the forthcoming 5.8.9 maintenance release, but haven't all been merged
in yet.)
I didn't mention my version of ActiveState Perl is 5.8.8 build 822. I had decided not to download a Perl Beta (5.10) but I would have had I known of the fix.

Rick
Post Reply