4

I'm trying to write a sample ImageMagick program in Visual Studio 2010. I have binary distribution of ImageMagick already installed on my system as I can use command line interface of ImageMagick.

However, when I try to include "Magick++.h" in my C++ program, it says it can't open source file.

I found the instructions on compiling and building ImageMagick from source, but is it possible to change my visual studio project settings so it can pick necessary references/libraries from the already installed version of ImageMagick?

pree
  • 2,297
  • 6
  • 37
  • 55

1 Answers1

5

I am by no means an expert, but here is what worked for me:

Using Windows7 Professional and Visual C++ Express 2010...

I checked the Install development headers and libraries for C and C++

install

At the end of the install, I got these two folders. Magick++.h lies inside include.

enter image description here

Be sure to set up your projects Additional Library Locations and Additional Include Directories and you should be able to compile your program.

Additionally: The manual suggests you need to do this for your program to work, but I did not and it still worked:

InitializeMagick(path_to_ImageMagick_DLLs);

And during my brief test, I found that Magick::Image::Magick() which changes image formats does not work in Debug mode. It does work in Release mode though.

Morpork
  • 551
  • 1
  • 6
  • 21
  • Where the hell did you get that setup? I downloaded the imagick zip archive bit there's nothing but a bunch of `.bat` files that produce errors and bunch of projects that can't be compiled... – Tomáš Zato Nov 22 '14 at 01:17
  • 1
    I used an installer. In the first screenshot's title, "ImageMagick 6.8.6 Q16 (32-bit). The version has changed since then but it's probably something called ImageMagick-6.9.0-0-Q16-x86-dll.exe, in this [page](http://www.imagemagick.org/script/binary-releases.php#windows). – Morpork Nov 22 '14 at 14:54
  • I've found it already but thank you anyway. It was incredibly hard struggle to get this library to work and it's still not completely working. – Tomáš Zato Nov 22 '14 at 14:56
  • I know this is very old, but @TomášZato were you ever able to get it to work? I'm trying to use it with VS2015 and I get an assortment of errors. "Unexpected token preceding ;", "syntaxerror: missing ';' before Identifier 'MagickBooleanType'" and so forth. – Goodies Jan 30 '16 at 06:23
  • @Goodies Yes I did manage to create gif images only. I have no idea how did I do it. – Tomáš Zato Jan 30 '16 at 13:07
  • As it turns out, I cannot use ImageMagick for what I want to do. I am writing a Python extension and, unfortunately, they each defined ssize_t differently. Python as an int and ImageMagick as a long. C++ does not allow redefinitions. I ended up having to use http://freeimage.sourceforge.net/ which is actually treating me very well. – Goodies Jan 30 '16 at 20:29
  • Hmm, I did this for 2017, and still get the same "Cannot open source file" error – Damien W May 15 '18 at 08:01
  • 1
    This adds the release DLL's only, if you want to do programming then you will need the debug DLL's. The debug DLL's can only be built from source. The trouble is that the IM source distribution is crap for windows and it is not possible to build anything. – ejectamenta May 24 '18 at 11:14