Magick++, VC++ 6.0, and Windows XP
Posted: 2013-04-19T22:15:42-07:00
I'm posting this here in the hopes that it will help someone else in my same situation. First, I can't afford the $600 that Microsoft wants to upgrade my VC++ compiler, so I'm stuck with the version 6.0 that I purchased several years ago. After several weeks of researching (about 2 months worth now), I've come to discover that there is not alot of direction or help with this topic. Let me tell you what I have found so far; I can download the ImageMagick source and compile a config program that's supposed to setup a build environment for vc++ 6.0, or, install the ImageMagick binary and setup a couple paths in vc++ 6.0 so it can find certain files.
Ok, for the first 4 to 5 weeks, I attempted the source approach because it seemed the most appropiate since I'm trying to write source. I tried downloading several versions of the source files from ImageMagick (even some older versions that I have archived in my library drive) and started following the directions. Please note, that between each attempt, I reloaded my computer from the restore disks so that there would be no conflict from previous attempts. In each attempt, the configure.dsw in the VisualMagic\configure folder seemed to build and run without any problems. The only change I made in the configure program was the option to create the dsw for vc++ 6.0 due to my requirements. After running the configure program then navigating to the VisualDynamicMT.dsw workspace and loading it, now it got nasty. I tried (several versions of the source files) to build and run the VisualDynamicMT.dsw as instructed (all, release, etc.) and ended up with a mound of errors (as I noticed from forum postings, lots of people have had), to which, never compiled. I battled with this for several weeks until I decided to try the "binary" approach.
The binary approach, well, I got a little further here. I installed (again several versions with the same tactics I used for the source attempts) the binary version of ImageMagick with the Magick++ option checked. I have been using PerlMagick for several years which is why I wanted to stay with it during my c++ quest, because, I just like it, and, I'm familiar with ImageMagicks' approaches. In fact, the program I'm trying to write in c++ is to be a port of a program I wrote in PerlMagick. I'm attempting to do this in c++ because the perl version has a couple of memory leaks and crashes every once in a while (days) and the computer has to be rebooted, but that's another issue. I have researched the perl2exe compiler and discovered it's not real efficient, and it actually packs a portion of the perl interpeter into the exe. Also, I really didn't want to have to install perl on every computer that I wanted to use this program (talk about in-efficiancy). Anyhow, back to my novel; After installing ImageMagick with it's appropiate options then adding a couple of paths to vc++ 6.0 so it could find the Imagemagick Files...
I tried to disect the demo files provided in the "C:\Program Files\ImageMagick-6.8.4-Q16\Magick++_Demo" folder pretty intensively, the only "program" I could compile and run without errors was the flip example which is what i used as an example. With the flip program as a kind-of template I came up with the (I might add successfull) source:
Note the added library pragmas due to vc++ 6.0 needed these directives because they don't come in the default setup, and rather than botch up the (working) compiler, I put them in the top of the source code. Perhaps I'm missing something here also.
So far, so good. As a footnote; the program I'm developing will read in an image (like from a camera) and then compares it to an image I have already saved (ie; motion) and decide whether or not to save the new image then create a seperate animation file. Again, I'm doing this with PerlMagick now. But, back to the novel; I started to do some document reading for Magick++, and supposidly, I should be able to use "ImageFrame.read(ImageName)" (with the proper "Image ImageFrame" declaration) for just one "frame" image instead of the multiple frame read I'm using above. Therefore, I attempted this:
Well, it compiled ok:
But after it builds and starts to run, I get a big window "Prog.exe has encountered a problem and needs to close. We are sorry for the inconvenience." and when I select the [Debug] button i get "Unhandled exception in Prog.exe (MSVCR100.DLL) 0xC0000005 Access Violation" with a pointer in the debug window to "78AA1ED7 rep movs dword ptr [edi],dword ptr [esi]" which I'm sure doesn't help, but, the program crashed.
I'm not fluent with c++, I'm learning as I go, but I am pretty good with assembly(machine) code, basic (of course), and perl, I have written several programs in those languages, but, as windows gets more complicated, it's getting harder to implement assembly into windows, which is why I'm hitting C++.
In closing my little novel here, my goal is to hopefully find someone out there that has successfully got Magick++, VC++ 6.0, and Windows XP to work together so the "ImageFrame.read" function, along with (I'm sure), "ImageFrame.compare" functions work in their source so I can continue my little adventure (Preferably, an idiots step by step *heh*). I'm sure I'm missing something, somewhere, somehow, but, without much documentation on the net about windows on this topic, I'm hoping someone can help with (maybe) an example of a simple read/write source using Magick++ with the appropiate "links", includes, headers, required (that I seem to be missing) to make it work with a fresh VC++ 6.0 with service pack and redistributable install similar to my example above.
Thanx for taking the time to read this. Your web browser will recieve a cookie soon.
-Gary
Ok, for the first 4 to 5 weeks, I attempted the source approach because it seemed the most appropiate since I'm trying to write source. I tried downloading several versions of the source files from ImageMagick (even some older versions that I have archived in my library drive) and started following the directions. Please note, that between each attempt, I reloaded my computer from the restore disks so that there would be no conflict from previous attempts. In each attempt, the configure.dsw in the VisualMagic\configure folder seemed to build and run without any problems. The only change I made in the configure program was the option to create the dsw for vc++ 6.0 due to my requirements. After running the configure program then navigating to the VisualDynamicMT.dsw workspace and loading it, now it got nasty. I tried (several versions of the source files) to build and run the VisualDynamicMT.dsw as instructed (all, release, etc.) and ended up with a mound of errors (as I noticed from forum postings, lots of people have had), to which, never compiled. I battled with this for several weeks until I decided to try the "binary" approach.
The binary approach, well, I got a little further here. I installed (again several versions with the same tactics I used for the source attempts) the binary version of ImageMagick with the Magick++ option checked. I have been using PerlMagick for several years which is why I wanted to stay with it during my c++ quest, because, I just like it, and, I'm familiar with ImageMagicks' approaches. In fact, the program I'm trying to write in c++ is to be a port of a program I wrote in PerlMagick. I'm attempting to do this in c++ because the perl version has a couple of memory leaks and crashes every once in a while (days) and the computer has to be rebooted, but that's another issue. I have researched the perl2exe compiler and discovered it's not real efficient, and it actually packs a portion of the perl interpeter into the exe. Also, I really didn't want to have to install perl on every computer that I wanted to use this program (talk about in-efficiancy). Anyhow, back to my novel; After installing ImageMagick with it's appropiate options then adding a couple of paths to vc++ 6.0 so it could find the Imagemagick Files...
Code: Select all
C:\PROGRAM FILES\IMAGEMAGICK-6.8.4-Q16\INCLUDE
C:\PROGRAM FILES\IMAGEMAGICK-6.8.4-Q16\INCLUDE\MAGICK
C:\PROGRAM FILES\IMAGEMAGICK-6.8.4-Q16\INCLUDE\MAGICK++
Code: Select all
#pragma comment(lib, "CORE_RL_Magick++_.lib")
#pragma comment(lib, "CORE_RL_Magick_.lib")
#include <Magick++.h>
#include <windows.h>
#include <string>
#include <list>
using namespace std;
using namespace Magick;
char *ImageName = "tigger.gif";
char *NewImageName = "test.gif";
int main( int /*argc*/, char ** argv) {
InitializeMagick(*argv);
try {
list<Image> ImageFrame;
readImages(&ImageFrame,ImageName);
writeImages(ImageFrame.begin(),ImageFrame.end(),NewImageName);
}
catch(exception &error_) {
printf("Exception Error:\n%s\n",error_.what());
return 1;
}
return 0;
}
So far, so good. As a footnote; the program I'm developing will read in an image (like from a camera) and then compares it to an image I have already saved (ie; motion) and decide whether or not to save the new image then create a seperate animation file. Again, I'm doing this with PerlMagick now. But, back to the novel; I started to do some document reading for Magick++, and supposidly, I should be able to use "ImageFrame.read(ImageName)" (with the proper "Image ImageFrame" declaration) for just one "frame" image instead of the multiple frame read I'm using above. Therefore, I attempted this:
Code: Select all
#pragma comment(lib, "CORE_RL_Magick++_.lib")
#pragma comment(lib, "CORE_RL_Magick_.lib")
#include <Magick++.h>
#include <windows.h>
#include <string>
#include <list>
using namespace std;
using namespace Magick;
char *ImageName = "tigger.gif";
char *NewImageName = "test.gif";
int main( int /*argc*/, char ** argv) {
InitializeMagick(*argv);
try {
Image ImageFrame;
ImageFrame.read(ImageName);
ImageFrame.write(NewImageName);
}
catch(exception &error_) {
printf("Exception Error:\n%s\n",error_.what());
return 1;
}
return 0;
}
Code: Select all
Compiling...
Prog.cpp
Linking...
Prog.exe - 0 error(s), 0 warning(s)
I'm not fluent with c++, I'm learning as I go, but I am pretty good with assembly(machine) code, basic (of course), and perl, I have written several programs in those languages, but, as windows gets more complicated, it's getting harder to implement assembly into windows, which is why I'm hitting C++.
In closing my little novel here, my goal is to hopefully find someone out there that has successfully got Magick++, VC++ 6.0, and Windows XP to work together so the "ImageFrame.read" function, along with (I'm sure), "ImageFrame.compare" functions work in their source so I can continue my little adventure (Preferably, an idiots step by step *heh*). I'm sure I'm missing something, somewhere, somehow, but, without much documentation on the net about windows on this topic, I'm hoping someone can help with (maybe) an example of a simple read/write source using Magick++ with the appropiate "links", includes, headers, required (that I seem to be missing) to make it work with a fresh VC++ 6.0 with service pack and redistributable install similar to my example above.
Thanx for taking the time to read this. Your web browser will recieve a cookie soon.
-Gary