Installing PerlMagick 6.3.7 with Visual Studio 2005 (VC++8)
Posted: 2007-12-05T22:43:45-07:00
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.
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
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):
(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:
Like this one, but with "perl.exe" in place of "app.exe" (apologies for stealing bandwidth from elsewhere):
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
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.
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.For Windows systems, type
perl Makefile.nt
nmake install
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'],
Code: Select all
'LIBS' => ['-L..\VisualMagick\lib -L..\VisualMagick\bin -lCORE_RL_magick_.lib -lCORE_DB_magick_.lib'],
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):
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