Simple HowTo for Windows/VS2012 wanted

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
bert.laverman
Posts: 6
Joined: 2014-03-09T05:51:58-07:00
Authentication code: 6789

Simple HowTo for Windows/VS2012 wanted

Post by bert.laverman »

I have downloaded ImageMagick and succeeded in building it, but am totally lost about how to write a simple test application with Magick++.

Can some kind soul enlighten me:
1) Do I actually need to install ImageMagick with all bells and whistles, or is there a simple developer install possible with only the libraries.
2) Where are the libraries in the ImageMagick tree after I build them? I found a VisualMagick\lib directory, but there is a huge collection of files in there and I don't know which of these I need.
3) Can I get a set of simple instructions on building an application using the libraries without the dependencies on the VisualMagick source tree? This may be a VS2012 thing, but I am used to having only a lib dir with libraries to link, instead of having to build all my projects as if they are part of the VisualMagick tree.

So:
- What is the minimal developer installation?
- What include directories do I need to add
- What library directories do I need to add
- What libraries do I need to link?

Kind of a KISS solution to writing applications with ImageMagick I was hoping for...

Cheers,
Bert
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Simple HowTo for Windows/VS2012 wanted

Post by dlemstra »

If you want to use Magick++ with VS2012 you will have to build it from source. The libraries that come with the installer are from VS2010.

The easiest way would be running configure.exe and choose 'Static Multi-hreaded DLL' runtimes. This will create a solution you can add your own project to. If you define 'STATIC_MAGICK' before you include 'Magick++.h' it will automatically link the necessary libraries.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
bert.laverman
Posts: 6
Joined: 2014-03-09T05:51:58-07:00
Authentication code: 6789

Re: Simple HowTo for Windows/VS2012 wanted

Post by bert.laverman »

dlemstra wrote:If you want to use Magick++ with VS2012 you will have to build it from source. The libraries that come with the installer are from VS2010.
Ok, I did get that, although the build failed for one component. However, since a number of demo applications built successfully, I thought I had enough to continue with.
dlemstra wrote:The easiest way would be running configure.exe and choose 'Static Multi-hreaded DLL' runtimes.
Eh, I think it was either static or else DLL, not static DLL.
dlemstra wrote:This will create a solution you can add your own project to.
The thing is that my own project is not part of the ImageMagick solution. It lives elsewhere and I'ld like to clean up the ImageMagick tree to only contain what I need for building applications with it. I don't need the programs or the VS project files, just the include files and the libraries.
dlemstra wrote:If you define 'STATIC_MAGICK' before you include 'Magick++.h' it will automatically link the necessary libraries.
When? Is this a runtime thing or a build-time thing? I can imagine the headers will contain extern declarations that will cause the dependency to be created, but if I don't tell the linker which .LIB's to include it won't pull them in by magic, will it?

Cheers,
Bert
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Simple HowTo for Windows/VS2012 wanted

Post by dlemstra »

The STATIC_MAGICK flag will enable the following:

#if defined(MAGICKCORE_BZLIB_DELEGATE)
# pragma comment(lib, "CORE_RL_bzlib_.lib")
#endif

This will tell VisualStudio to automatically link CORE_RL_bzlib_.lib. All the necessary libraries will be linked depending on the delegates you enable in magick-baseconfig.h. All the libraries are located in VisualMagick\lib. You should include only include Magick++.h and add the following include directories: magick, Magick++\lib, wand.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
bert.laverman
Posts: 6
Joined: 2014-03-09T05:51:58-07:00
Authentication code: 6789

Re: Simple HowTo for Windows/VS2012 wanted

Post by bert.laverman »

dlemstra wrote:The STATIC_MAGICK flag will enable the following:

#if defined(MAGICKCORE_BZLIB_DELEGATE)
# pragma comment(lib, "CORE_RL_bzlib_.lib")
#endif

This will tell VisualStudio to automatically link CORE_RL_bzlib_.lib. All the necessary libraries will be linked depending on the delegates you enable in magick-baseconfig.h. All the libraries are located in VisualMagick\lib. You should include only include Magick++.h and add the following include directories: magick, Magick++\lib, wand.
Great, that sounds like a plan. Will post results as soon as available. :)

Cheers,
Bert
bert.laverman
Posts: 6
Joined: 2014-03-09T05:51:58-07:00
Authentication code: 6789

Re: Simple HowTo for Windows/VS2012 wanted

Post by bert.laverman »

Ok, update.

That build error was most likely the result of a configure-build-clean-reconfigure-rebuild. A wipe-unzip-configure-build cycle gave no errors.

My static vs DLL confusion turns out to be ImageMagick libs vs C/C++ runtime: "static MT DLL" means ImageMagick as .LIB's, C/C++ runtime as DLL's, so for ImageMagick as DLL (I suppose that includes the dynamic loading of modules and such) you have to use Multi-threaded DLL runtime, whereas the statically linked ImageMagick can support all 4 runtime variants. (ST/MT, LIB/DLL)

Haven't been able to get working application yet, as halfway our kitten decided to ascend my leg and start investigating desk and keyboard.

Cheers,
Bert
bert.laverman
Posts: 6
Joined: 2014-03-09T05:51:58-07:00
Authentication code: 6789

Re: Simple HowTo for Windows/VS2012 wanted

Post by bert.laverman »

Ok,
something basic is not working for me.

- Built the static MT DLL version without errors.
Test program hangs in the Magick::InitializeMagick() method, while trying to acquire a lock. This is so deep in the basic ImageMagick stuff I'm not going to waste time on it, because I don't have the intimate knowledge of ImageMagick. If someone recognizes this behaviour please tell me.

- Built a default dynamic MT DLL version. First try without errors, but I did leave out the demos and such.
At link time VS states the CORE_DB_coders_.lib cannot be found. I searched, it has not been built by the VisualMagick runtime; there is no project for it.

- Tried a fresh build with only demos added in. ImageMagick build throws some error but largely succeeds. CORE_DB_coders_ still not there though.

Has anyone ever gotten this to work with VS 2012? I'm not changing anything in the ImageMagick stuff itself. I would like to have the static build, because then I won't have to saddle up others with installing ImageMagick when they just want my program.

Help, anyone?
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Simple HowTo for Windows/VS2012 wanted

Post by dlemstra »

Test program hangs in the Magick::InitializeMagick() method, while trying to acquire a lock. This is so deep in the basic ImageMagick stuff I'm not going to waste time on it, because I don't have the intimate knowledge of ImageMagick. If someone recognizes this behaviour please tell me.
Did you enable OpenMP? We recently fixed a deadlock that occurred when the code was build on Windows without OpenMP. Can you try to enable this and see if it works?
At link time VS states the CORE_DB_coders_.lib cannot be found. I searched, it has not been built by the VisualMagick runtime; there is no project for it.
Did you remove the define for STATIC_MAGICK? You cannot use the STATIC_MAGICK with the dynamic build. I would however advise you to use a static build in your situation.
Has anyone ever gotten this to work with VS 2012?
Magick.NET (C# api for ImageMagick) uses a static build of ImageMagick in VS 2012.
saddle up
De up is niet nodig in het Engels :)
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
bert.laverman
Posts: 6
Joined: 2014-03-09T05:51:58-07:00
Authentication code: 6789

Re: Simple HowTo for Windows/VS2012 wanted

Post by bert.laverman »

Did you enable OpenMP? We recently fixed a deadlock that occurred when the code was build on Windows without OpenMP. Can you try to enable this and see if it works?
Ah, I disabled it to get a "Lean and Mean" build. Retested and it now works.

Mijn dank is groot...

Bert
Post Reply