How to Link to MagickWand library statically?

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
alanchcw
Posts: 7
Joined: 2019-09-29T02:11:05-07:00
Authentication code: 1152

How to Link to MagickWand library statically?

Post by alanchcw » 2019-10-01T23:28:03-07:00

Hi,

I follow the instructions in https://imagemagick.org/script/advanced ... lation.php and build ImageMagick as "Static Multi-threaded runtimes" settings.

Then I create a test project TestMagick and add https://imagemagick.org/source/wand.c to my project.

Then I add the following path to project's Additional Include Directories:

E:\ImageMagick-7.0.8-66\ImageMagick\

Then I add the following path to project's Additonal Library Directories:

E:\ImageMagick-7.0.8-66\VisualMagick\lib

Then I add these two library files as project's Additonal Dependencies:

CORE_RL_MagickCore_lib;CORE_RL_MagickWand.lib

Then I built my project as Release version.

But I get the following link errors:

TestMagick.obj: Error LNK2001: unresolved external symbol __imp__MagicWandGenesis
TestMagick.obj: Error LNK2001: unresolved external symbol __imp__NewMagickWand
...

Since the functions are started with __imp, it seems I should linked with DLL import library instead of static library.

Therefore, I try to rebuild ImageMagick as "Dynamic Multi-threaded DLL runtimes". Then rebuild TestMagick. Now this time, the build is successfully.
However, TestMagick must be placed under ImageMagick's bin directory since it will use a lot of ImageMagick DLLs.

Therefore, I still want to be able to build my project with ImageWand statically. So How to do that?

Thanks

Post Reply