Page 1 of 1

How to Link to MagickWand library statically?

Posted: 2019-10-01T23:28:03-07:00
by alanchcw
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