I’ve done the majority of my coding in Unix and Linux environments, so I’ve gotten used to the way they do things. Visual Studio 2010 has been a bit of an adjustment (with one or two headaches). I thought I’d write some tips in case this happens to be one of your headaches too.
I kept getting the error: “Unhandled exception … in …exe Access violation writing location” when trying to run Magick++ using the image class image(“my.image.jpg”). Everything else worked fine, and it took a while to figure out the problem so I provide the solution below (and everything else I did so you can get the whole picture).
If you’re trying to configure Magick++, there are a few things you want to make sure to do. First off open up the demo that installs as Magick++_Demo and right click on any of the projects. After clicking properties you’ll get the Property Page.
From there you’ll want to go to click on the arrow next to the “Linker” group, click on it and then click on “Input”. There you’ll find “Additional Dependencies”. In my case I copied all of this which happened to be:
CORE_RL_magick_.lib
CORE_RL_Magick++_.lib
X11.lib
odbc32.lib
odbccp32.lib
winmm.lib
wsock32.lib
You’ll also want to go to the “General” tab (also under “Linker”), and find the folder pointed to in the demo and put it in yours with the right path for “Additional Library Directories”.
Under “C/C++” click on “General” and do the same with “Additional Include Directories” there. It’s also good to go to “VC++ Directories” and choose “Include Directories” and add ImageMagick’s include (for me that was ImageMagick-6.6.5-Q16\include) and under “Library Directories” add the lib directory (same as last but lib instead of include).
The kicker, and the setting that took me the longest to discover and change is under “Configuration Properties/C/C++/Code Generation”. Make sure the “Runtime Library” is set to “Multi-Threaded DLL (/MD)” and not to “Multi-Threaded Debug DLL (/MDd)” which is the default for the Debug setup. Then under “Configuration Properties/C/C++/Preprocessor” I read some people had to change the “Preprocessor Definition” that is set to “_DEBUG” to “NDEBUG” (for me nothing was set so I left it alone).
Hopefully this helps anyone else that ran into the dreaded “Unhandled exception at… in… Access violation writing location” error. I’ll post screen shots if I get a minute (chances are I won’t unless you ask).
Thank you for your post.
I also have the same issue trying to use Magick++ in 2 different enviroments:
ImageMagick-6.0.2-Q16 + Windows XP + Visual C++ 6.0
ImageMagick-6.6.7-Q16 + Windows 7 x64 + Visual C++ 6.0
In both cases I’ve used the windows installer version to install ImageMagick. I’ve added include and lib folders to Visual Studio. And I’m using the “Magick++_Demo”.
I’ve checked that all project options are that they should be.
But I still get the “Unhandled exception … in …exe Access violation writing location” message error when debugging for instance the button.exe example.
Do you have any advice to give me to try to fix this error?
Maybe, I would be useful if you could upload an example solution for Visual Studio using Magick++.
Thank you so much.
Thanks man! I had like five days trying to figure this out. The worst part is that I have had similar problems before (Multi-Threaded vs Multi-Threaded Debug), but I still don’t learn!
Thank you again